runtime/vm/benchmark_test.cc
//
// Measure compile of all kernel Service(CFE) functions.
//
Measure compile of all kernel Service(CFE) functions.
Measure compile of all kernel Service ( CFE ) functions .
BENCHMARK(KernelServiceCompileAll) {
  bin::Builtin::SetNativeResolver(bin::Builtin::kBuiltinLibrary);
  bin::Builtin::SetNativeResolver(bin::Builtin::kIOLibrary);
  bin::Builtin::SetNativeResolver(bin::Builtin::kCLILibrary);
  char* dill_path = ComputeKernelServicePath(Benchmark::Executable());
  File* file = File::Open(NULL, dill_path, File::kRead);
  EXPECT(file != NULL);
  bin::RefCntReleaseScope<File> rs(file);
  intptr_t kernel_buffer_size = file->Length();
  uint8_t* kernel_buffer =
      reinterpret_cast<uint8_t*>(malloc(kernel_buffer_size));
  EXPECT(kernel_buffer != NULL);
  bool read_fully = file->ReadFully(kernel_buffer, kernel_buffer_size);
  EXPECT(read_fully);
  Dart_Handle result =
      Dart_LoadScriptFromKernel(kernel_buffer, kernel_buffer_size);
  EXPECT_VALID(result);
  Dart_Handle service_lib = Dart_LookupLibrary(NewString("dart:vmservice_io"));
  ASSERT(!Dart_IsError(service_lib));
  Dart_SetNativeResolver(
      service_lib, reinterpret_cast<Dart_NativeEntryResolver>(NativeResolver),
      NULL);
  result = Dart_FinalizeLoading(false);
  EXPECT_VALID(result);
  Timer timer(true, "Compile all of kernel service benchmark");
  timer.Start();
#if !defined(PRODUCT)
  const bool old_flag = FLAG_background_compilation;
  FLAG_background_compilation = false;
#endif
  result = Dart_CompileAll();
#if !defined(PRODUCT)
  FLAG_background_compilation = old_flag;
#endif
  EXPECT_VALID(result);
  timer.Stop();
  int64_t elapsed_time = timer.TotalElapsedTime();
  benchmark->set_score(elapsed_time);
  free(dill_path);
  free(kernel_buffer);
}
BENCHMARK ( KernelServiceCompileAll ) { bin :: Builtin :: SetNativeResolver ( bin :: Builtin :: kBuiltinLibrary ) ; bin :: Builtin :: SetNativeResolver ( bin :: Builtin :: kIOLibrary ) ; bin :: Builtin :: SetNativeResolver ( bin :: Builtin :: kCLILibrary ) ; char * dill_path = ComputeKernelServicePath ( Benchmark :: Executable ( ) ) ; File * file = File :: Open ( NULL , dill_path , File :: kRead ) ; EXPECT ( file != NULL ) ; bin :: RefCntReleaseScope < File > rs ( file ) ; intptr_t kernel_buffer_size = file -> Length ( ) ; uint8_t * kernel_buffer = reinterpret_cast < uint8_t * > ( malloc ( kernel_buffer_size ) ) ; EXPECT ( kernel_buffer != NULL ) ; bool read_fully = file -> ReadFully ( kernel_buffer , kernel_buffer_size ) ; EXPECT ( read_fully ) ; Dart_Handle result = Dart_LoadScriptFromKernel ( kernel_buffer , kernel_buffer_size ) ; EXPECT_VALID ( result ) ; Dart_Handle service_lib = Dart_LookupLibrary ( NewString ( " " ) ) ; ASSERT ( ! Dart_IsError ( service_lib ) ) ; Dart_SetNativeResolver ( service_lib , reinterpret_cast < Dart_NativeEntryResolver > ( NativeResolver ) , NULL ) ; result = Dart_FinalizeLoading ( false ) ; EXPECT_VALID ( result ) ; Timer timer ( true , " " ) ; timer . Start ( ) ; #if ! defined ( PRODUCT ) const bool old_flag = FLAG_background_compilation ; FLAG_background_compilation = false ; #endif result = Dart_CompileAll ( ) ; #if ! defined ( PRODUCT ) FLAG_background_compilation = old_flag ; #endif EXPECT_VALID ( result ) ; timer . Stop ( ) ; int64_t elapsed_time = timer . TotalElapsedTime ( ) ; benchmark -> set_score ( elapsed_time ) ; free ( dill_path ) ; free ( kernel_buffer ) ; }
Measure compile of all kernel Service(CFE) functions.
Measure compile of all kernel Service ( CFE ) functions .