runtime/vm/benchmark_test.cc
// Unit test case to verify stack frame iteration.
Unit test case to verify stack frame iteration.
Unit test case to verify stack frame iteration .
BENCHMARK(FrameLookup) {
  const char* kScriptChars =
      "class StackFrame {"
      "  static int accessFrame() native \"StackFrame_accessFrame\";"
      "} "
      "class First {"
      "  First() { }"
      "  int method1(int param) {"
      "    if (param == 1) {"
      "      param = method2(200);"
      "    } else {"
      "      param = method2(100);"
      "    }"
      "    return param;"
      "  }"
      "  int method2(int param) {"
      "    if (param == 200) {"
      "      return First.staticmethod(this, param);"
      "    } else {"
      "      return First.staticmethod(this, 10);"
      "    }"
      "  }"
      "  static int staticmethod(First obj, int param) {"
      "    if (param == 10) {"
      "      return obj.method3(10);"
      "    } else {"
      "      return obj.method3(200);"
      "    }"
      "  }"
      "  int method3(int param) {"
      "    return StackFrame.accessFrame();"
      "  }"
      "}"
      "class StackFrameTest {"
      "  static int testMain() {"
      "    First obj = new First();"
      "    return obj.method1(1);"
      "  }"
      "}";
  Dart_Handle lib = TestCase::LoadTestScript(
      kScriptChars,
      reinterpret_cast<Dart_NativeEntryResolver>(StackFrameNativeResolver));
  Dart_Handle cls = Dart_GetClass(lib, NewString("StackFrameTest"));
  Dart_Handle result = Dart_Invoke(cls, NewString("testMain"), 0, NULL);
  EXPECT_VALID(result);
  int64_t elapsed_time = 0;
  result = Dart_IntegerToInt64(result, &elapsed_time);
  EXPECT_VALID(result);
  benchmark->set_score(elapsed_time);
}
BENCHMARK ( FrameLookup ) { const char * kScriptChars = " " " \" \" " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " ; Dart_Handle lib = TestCase :: LoadTestScript ( kScriptChars , reinterpret_cast < Dart_NativeEntryResolver > ( StackFrameNativeResolver ) ) ; Dart_Handle cls = Dart_GetClass ( lib , NewString ( " " ) ) ; Dart_Handle result = Dart_Invoke ( cls , NewString ( " " ) , 0 , NULL ) ; EXPECT_VALID ( result ) ; int64_t elapsed_time = 0 ; result = Dart_IntegerToInt64 ( result , & elapsed_time ) ; EXPECT_VALID ( result ) ; benchmark -> set_score ( elapsed_time ) ; }
Unit test case to verify stack frame iteration.
Unit test case to verify stack frame iteration .