OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/benchmark_test.h" | 5 #include "vm/benchmark_test.h" |
6 | 6 |
7 #include "bin/builtin.h" | 7 #include "bin/builtin.h" |
8 #include "bin/file.h" | 8 #include "bin/file.h" |
9 | 9 |
10 #include "platform/assert.h" | 10 #include "platform/assert.h" |
11 #include "platform/globals.h" | 11 #include "platform/globals.h" |
12 | 12 |
| 13 #include "vm/compiler_stats.h" |
13 #include "vm/dart_api_impl.h" | 14 #include "vm/dart_api_impl.h" |
14 #include "vm/stack_frame.h" | 15 #include "vm/stack_frame.h" |
15 #include "vm/unit_test.h" | 16 #include "vm/unit_test.h" |
16 | 17 |
17 using dart::bin::File; | 18 using dart::bin::File; |
18 | 19 |
19 namespace dart { | 20 namespace dart { |
20 | 21 |
21 Benchmark* Benchmark::first_ = NULL; | 22 Benchmark* Benchmark::first_ = NULL; |
22 Benchmark* Benchmark::tail_ = NULL; | 23 Benchmark* Benchmark::tail_ = NULL; |
(...skipping 16 matching lines...) Expand all Loading... |
39 bin::Builtin::SetNativeResolver(bin::Builtin::kBuiltinLibrary); | 40 bin::Builtin::SetNativeResolver(bin::Builtin::kBuiltinLibrary); |
40 bin::Builtin::SetNativeResolver(bin::Builtin::kIOLibrary); | 41 bin::Builtin::SetNativeResolver(bin::Builtin::kIOLibrary); |
41 Timer timer(true, "Compile all of Core lib benchmark"); | 42 Timer timer(true, "Compile all of Core lib benchmark"); |
42 timer.Start(); | 43 timer.Start(); |
43 const Error& error = Error::Handle(benchmark->isolate(), | 44 const Error& error = Error::Handle(benchmark->isolate(), |
44 Library::CompileAll()); | 45 Library::CompileAll()); |
45 if (!error.IsNull()) { | 46 if (!error.IsNull()) { |
46 OS::PrintErr("Unexpected error in CorelibCompileAll benchmark:\n%s", | 47 OS::PrintErr("Unexpected error in CorelibCompileAll benchmark:\n%s", |
47 error.ToErrorCString()); | 48 error.ToErrorCString()); |
48 } | 49 } |
49 EXPECT(error.IsNull()); | |
50 timer.Stop(); | 50 timer.Stop(); |
51 int64_t elapsed_time = timer.TotalElapsedTime(); | 51 int64_t elapsed_time = timer.TotalElapsedTime(); |
52 benchmark->set_score(elapsed_time); | 52 benchmark->set_score(elapsed_time); |
| 53 } |
| 54 |
| 55 |
| 56 BENCHMARK(CorelibCompilerStats) { |
| 57 bin::Builtin::SetNativeResolver(bin::Builtin::kBuiltinLibrary); |
| 58 bin::Builtin::SetNativeResolver(bin::Builtin::kIOLibrary); |
| 59 CompilerStats* stats = Isolate::Current()->compiler_stats(); |
| 60 ASSERT(stats != NULL); |
| 61 stats->EnableBenchmark(); |
| 62 Timer timer(true, "Compiler stats compiling all of Core lib"); |
| 63 timer.Start(); |
| 64 const Error& error = Error::Handle(benchmark->isolate(), |
| 65 Library::CompileAll()); |
| 66 if (!error.IsNull()) { |
| 67 OS::PrintErr("Unexpected error in CorelibCompileAll benchmark:\n%s", |
| 68 error.ToErrorCString()); |
| 69 } |
| 70 timer.Stop(); |
| 71 int64_t elapsed_time = timer.TotalElapsedTime(); |
| 72 benchmark->set_score(elapsed_time); |
53 } | 73 } |
54 | 74 |
55 | 75 |
56 // | 76 // |
57 // Measure creation of core isolate from a snapshot. | 77 // Measure creation of core isolate from a snapshot. |
58 // | 78 // |
59 BENCHMARK(CorelibIsolateStartup) { | 79 BENCHMARK(CorelibIsolateStartup) { |
60 const int kNumIterations = 1000; | 80 const int kNumIterations = 1000; |
61 Timer timer(true, "CorelibIsolateStartup"); | 81 Timer timer(true, "CorelibIsolateStartup"); |
62 Isolate* isolate = Isolate::Current(); | 82 Isolate* isolate = Isolate::Current(); |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 Dart_Handle result = Dart_CompileAll(); | 391 Dart_Handle result = Dart_CompileAll(); |
372 EXPECT_VALID(result); | 392 EXPECT_VALID(result); |
373 timer.Stop(); | 393 timer.Stop(); |
374 int64_t elapsed_time = timer.TotalElapsedTime(); | 394 int64_t elapsed_time = timer.TotalElapsedTime(); |
375 benchmark->set_score(elapsed_time); | 395 benchmark->set_score(elapsed_time); |
376 free(dart_root); | 396 free(dart_root); |
377 free(script); | 397 free(script); |
378 } | 398 } |
379 | 399 |
380 | 400 |
| 401 BENCHMARK(Dart2JSCompilerStats) { |
| 402 bin::Builtin::SetNativeResolver(bin::Builtin::kBuiltinLibrary); |
| 403 bin::Builtin::SetNativeResolver(bin::Builtin::kIOLibrary); |
| 404 SetupDart2JSPackagePath(); |
| 405 char* dart_root = ComputeDart2JSPath(Benchmark::Executable()); |
| 406 char* script = NULL; |
| 407 if (dart_root != NULL) { |
| 408 HANDLESCOPE(thread); |
| 409 script = OS::SCreate(NULL, |
| 410 "import '%s/pkg/compiler/lib/compiler.dart';", dart_root); |
| 411 Dart_Handle lib = TestCase::LoadTestScript( |
| 412 script, |
| 413 reinterpret_cast<Dart_NativeEntryResolver>(NativeResolver)); |
| 414 EXPECT_VALID(lib); |
| 415 } else { |
| 416 Dart_Handle lib = TestCase::LoadTestScript( |
| 417 "import 'pkg/compiler/lib/compiler.dart';", |
| 418 reinterpret_cast<Dart_NativeEntryResolver>(NativeResolver)); |
| 419 EXPECT_VALID(lib); |
| 420 } |
| 421 CompilerStats* stats = Isolate::Current()->compiler_stats(); |
| 422 ASSERT(stats != NULL); |
| 423 stats->EnableBenchmark(); |
| 424 Timer timer(true, "Compile all of dart2js benchmark"); |
| 425 timer.Start(); |
| 426 Dart_Handle result = Dart_CompileAll(); |
| 427 EXPECT_VALID(result); |
| 428 timer.Stop(); |
| 429 int64_t elapsed_time = timer.TotalElapsedTime(); |
| 430 benchmark->set_score(elapsed_time); |
| 431 free(dart_root); |
| 432 free(script); |
| 433 } |
| 434 |
| 435 |
381 // | 436 // |
382 // Measure frame lookup during stack traversal. | 437 // Measure frame lookup during stack traversal. |
383 // | 438 // |
384 static void StackFrame_accessFrame(Dart_NativeArguments args) { | 439 static void StackFrame_accessFrame(Dart_NativeArguments args) { |
385 const int kNumIterations = 100; | 440 const int kNumIterations = 100; |
386 Code& code = Code::Handle(); | 441 Code& code = Code::Handle(); |
387 Timer timer(true, "LookupDartCode benchmark"); | 442 Timer timer(true, "LookupDartCode benchmark"); |
388 timer.Start(); | 443 timer.Start(); |
389 for (int i = 0; i < kNumIterations; i++) { | 444 for (int i = 0; i < kNumIterations; i++) { |
390 StackFrameIterator frames(StackFrameIterator::kDontValidateFrames); | 445 StackFrameIterator frames(StackFrameIterator::kDontValidateFrames); |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
695 thread); | 750 thread); |
696 reader.ReadObject(); | 751 reader.ReadObject(); |
697 free(buffer); | 752 free(buffer); |
698 } | 753 } |
699 timer.Stop(); | 754 timer.Stop(); |
700 int64_t elapsed_time = timer.TotalElapsedTime(); | 755 int64_t elapsed_time = timer.TotalElapsedTime(); |
701 benchmark->set_score(elapsed_time); | 756 benchmark->set_score(elapsed_time); |
702 } | 757 } |
703 | 758 |
704 } // namespace dart | 759 } // namespace dart |
OLD | NEW |