Index: runtime/vm/benchmark_test.cc |
diff --git a/runtime/vm/benchmark_test.cc b/runtime/vm/benchmark_test.cc |
index 36dfae27797d72ec5a02f76271019f3f8ce867b7..900a689a3d8152610165f4eb8fb6b27265a35b0f 100644 |
--- a/runtime/vm/benchmark_test.cc |
+++ b/runtime/vm/benchmark_test.cc |
@@ -10,6 +10,7 @@ |
#include "platform/assert.h" |
#include "platform/globals.h" |
+#include "vm/compiler_stats.h" |
#include "vm/dart_api_impl.h" |
#include "vm/stack_frame.h" |
#include "vm/unit_test.h" |
@@ -46,7 +47,26 @@ BENCHMARK(CorelibCompileAll) { |
OS::PrintErr("Unexpected error in CorelibCompileAll benchmark:\n%s", |
error.ToErrorCString()); |
} |
- EXPECT(error.IsNull()); |
+ timer.Stop(); |
+ int64_t elapsed_time = timer.TotalElapsedTime(); |
+ benchmark->set_score(elapsed_time); |
+} |
+ |
+ |
+BENCHMARK(CorelibCompilerStats) { |
+ bin::Builtin::SetNativeResolver(bin::Builtin::kBuiltinLibrary); |
+ bin::Builtin::SetNativeResolver(bin::Builtin::kIOLibrary); |
+ CompilerStats* stats = Isolate::Current()->compiler_stats(); |
+ ASSERT(stats != NULL); |
+ stats->EnableBenchmark(); |
+ Timer timer(true, "Compiler stats compiling all of Core lib"); |
+ timer.Start(); |
+ const Error& error = Error::Handle(benchmark->isolate(), |
+ Library::CompileAll()); |
+ if (!error.IsNull()) { |
+ OS::PrintErr("Unexpected error in CorelibCompileAll benchmark:\n%s", |
+ error.ToErrorCString()); |
+ } |
timer.Stop(); |
int64_t elapsed_time = timer.TotalElapsedTime(); |
benchmark->set_score(elapsed_time); |
@@ -378,6 +398,41 @@ BENCHMARK(Dart2JSCompileAll) { |
} |
+BENCHMARK(Dart2JSCompilerStats) { |
+ bin::Builtin::SetNativeResolver(bin::Builtin::kBuiltinLibrary); |
+ bin::Builtin::SetNativeResolver(bin::Builtin::kIOLibrary); |
+ SetupDart2JSPackagePath(); |
+ char* dart_root = ComputeDart2JSPath(Benchmark::Executable()); |
+ char* script = NULL; |
+ if (dart_root != NULL) { |
+ HANDLESCOPE(thread); |
+ script = OS::SCreate(NULL, |
+ "import '%s/pkg/compiler/lib/compiler.dart';", dart_root); |
+ Dart_Handle lib = TestCase::LoadTestScript( |
+ script, |
+ reinterpret_cast<Dart_NativeEntryResolver>(NativeResolver)); |
+ EXPECT_VALID(lib); |
+ } else { |
+ Dart_Handle lib = TestCase::LoadTestScript( |
+ "import 'pkg/compiler/lib/compiler.dart';", |
+ reinterpret_cast<Dart_NativeEntryResolver>(NativeResolver)); |
+ EXPECT_VALID(lib); |
+ } |
+ CompilerStats* stats = Isolate::Current()->compiler_stats(); |
+ ASSERT(stats != NULL); |
+ stats->EnableBenchmark(); |
+ Timer timer(true, "Compile all of dart2js benchmark"); |
+ timer.Start(); |
+ Dart_Handle result = Dart_CompileAll(); |
+ EXPECT_VALID(result); |
+ timer.Stop(); |
+ int64_t elapsed_time = timer.TotalElapsedTime(); |
+ benchmark->set_score(elapsed_time); |
+ free(dart_root); |
+ free(script); |
+} |
+ |
+ |
// |
// Measure frame lookup during stack traversal. |
// |