runtime/vm/benchmark_test.cc
//
// Measure frame lookup during stack traversal.
//
Measure frame lookup during stack traversal.
Measure frame lookup during stack traversal .
static void StackFrame_accessFrame(Dart_NativeArguments args) {
  Timer timer(true, "LookupDartCode benchmark");
  timer.Start();
  {
    Thread* thread = Thread::Current();
    TransitionNativeToVM transition(thread);
    const int kNumIterations = 100;
    Code& code = Code::Handle(thread->zone());
    Bytecode& bytecode = Bytecode::Handle(thread->zone());
    for (int i = 0; i < kNumIterations; i++) {
      StackFrameIterator frames(ValidationPolicy::kDontValidateFrames, thread,
                                StackFrameIterator::kNoCrossThreadIteration);
      StackFrame* frame = frames.NextFrame();
      while (frame != NULL) {
        if (frame->IsStubFrame()) {
          code = frame->LookupDartCode();
          EXPECT(code.function() == Function::null());
        } else if (frame->IsDartFrame()) {
          if (frame->is_interpreted()) {
            bytecode = frame->LookupDartBytecode();
            EXPECT(bytecode.function() != Function::null());
          } else {
            code = frame->LookupDartCode();
            EXPECT(code.function() != Function::null());
          }
        }
        frame = frames.NextFrame();
      }
    }
  }
  timer.Stop();
  int64_t elapsed_time = timer.TotalElapsedTime();
  Dart_SetReturnValue(args, Dart_NewInteger(elapsed_time));
}
static void StackFrame_accessFrame ( Dart_NativeArguments args ) { Timer timer ( true , " " ) ; timer . Start ( ) ; { Thread * thread = Thread :: Current ( ) ; TransitionNativeToVM transition ( thread ) ; const int kNumIterations = 100 ; Code & code = Code :: Handle ( thread -> zone ( ) ) ; Bytecode & bytecode = Bytecode :: Handle ( thread -> zone ( ) ) ; for ( int i = 0 ; i < kNumIterations ; i ++ ) { StackFrameIterator frames ( ValidationPolicy :: kDontValidateFrames , thread , StackFrameIterator :: kNoCrossThreadIteration ) ; StackFrame * frame = frames . NextFrame ( ) ; while ( frame != NULL ) { if ( frame -> IsStubFrame ( ) ) { code = frame -> LookupDartCode ( ) ; EXPECT ( code . function ( ) == Function :: null ( ) ) ; } else if ( frame -> IsDartFrame ( ) ) { if ( frame -> is_interpreted ( ) ) { bytecode = frame -> LookupDartBytecode ( ) ; EXPECT ( bytecode . function ( ) != Function :: null ( ) ) ; } else { code = frame -> LookupDartCode ( ) ; EXPECT ( code . function ( ) != Function :: null ( ) ) ; } } frame = frames . NextFrame ( ) ; } } } timer . Stop ( ) ; int64_t elapsed_time = timer . TotalElapsedTime ( ) ; Dart_SetReturnValue ( args , Dart_NewInteger ( elapsed_time ) ) ; }
Measure frame lookup during stack traversal.
Measure frame lookup during stack traversal .