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 23 matching lines...) Expand all Loading... | |
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 EXPECT(error.IsNull()); |
50 timer.Stop(); | 51 timer.Stop(); |
51 int64_t elapsed_time = timer.TotalElapsedTime(); | 52 int64_t elapsed_time = timer.TotalElapsedTime(); |
52 benchmark->set_score(elapsed_time); | 53 benchmark->set_score(elapsed_time); |
53 } | 54 } |
54 | 55 |
55 | 56 |
57 BENCHMARK(CorelibCompilerStats) { | |
58 bin::Builtin::SetNativeResolver(bin::Builtin::kBuiltinLibrary); | |
59 bin::Builtin::SetNativeResolver(bin::Builtin::kIOLibrary); | |
60 CompilerStats* stats = Isolate::Current()->compiler_stats(); | |
61 ASSERT(stats != NULL); | |
62 stats->EnableBenchmark(); | |
63 Timer timer(true, "Compiler stats compiling all of Core lib"); | |
64 timer.Start(); | |
65 const Error& error = Error::Handle(benchmark->isolate(), | |
66 Library::CompileAll()); | |
67 if (!error.IsNull()) { | |
68 OS::PrintErr("Unexpected error in CorelibCompileAll benchmark:\n%s", | |
69 error.ToErrorCString()); | |
70 } | |
71 EXPECT(error.IsNull()); | |
siva
2015/09/16 17:25:00
The 'EXPECT(error.IsNull())' line seems to make th
hausner
2015/09/16 18:21:01
Done, also in the the code above.
| |
72 timer.Stop(); | |
73 int64_t elapsed_time = timer.TotalElapsedTime(); | |
74 benchmark->set_score(elapsed_time); | |
75 } | |
76 | |
77 | |
56 // | 78 // |
57 // Measure creation of core isolate from a snapshot. | 79 // Measure creation of core isolate from a snapshot. |
58 // | 80 // |
59 BENCHMARK(CorelibIsolateStartup) { | 81 BENCHMARK(CorelibIsolateStartup) { |
60 const int kNumIterations = 1000; | 82 const int kNumIterations = 1000; |
61 Timer timer(true, "CorelibIsolateStartup"); | 83 Timer timer(true, "CorelibIsolateStartup"); |
62 Isolate* isolate = Isolate::Current(); | 84 Isolate* isolate = Isolate::Current(); |
63 Thread::ExitIsolate(); | 85 Thread::ExitIsolate(); |
64 for (int i = 0; i < kNumIterations; i++) { | 86 for (int i = 0; i < kNumIterations; i++) { |
65 timer.Start(); | 87 timer.Start(); |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
371 Dart_Handle result = Dart_CompileAll(); | 393 Dart_Handle result = Dart_CompileAll(); |
372 EXPECT_VALID(result); | 394 EXPECT_VALID(result); |
373 timer.Stop(); | 395 timer.Stop(); |
374 int64_t elapsed_time = timer.TotalElapsedTime(); | 396 int64_t elapsed_time = timer.TotalElapsedTime(); |
375 benchmark->set_score(elapsed_time); | 397 benchmark->set_score(elapsed_time); |
376 free(dart_root); | 398 free(dart_root); |
377 free(script); | 399 free(script); |
378 } | 400 } |
379 | 401 |
380 | 402 |
403 BENCHMARK(Dart2JSCompilerStats) { | |
404 bin::Builtin::SetNativeResolver(bin::Builtin::kBuiltinLibrary); | |
405 bin::Builtin::SetNativeResolver(bin::Builtin::kIOLibrary); | |
406 SetupDart2JSPackagePath(); | |
407 char* dart_root = ComputeDart2JSPath(Benchmark::Executable()); | |
408 char* script = NULL; | |
409 if (dart_root != NULL) { | |
410 HANDLESCOPE(thread); | |
411 script = OS::SCreate(NULL, | |
412 "import '%s/pkg/compiler/lib/compiler.dart';", dart_root); | |
413 Dart_Handle lib = TestCase::LoadTestScript( | |
414 script, | |
415 reinterpret_cast<Dart_NativeEntryResolver>(NativeResolver)); | |
416 EXPECT_VALID(lib); | |
417 } else { | |
418 Dart_Handle lib = TestCase::LoadTestScript( | |
419 "import 'pkg/compiler/lib/compiler.dart';", | |
420 reinterpret_cast<Dart_NativeEntryResolver>(NativeResolver)); | |
421 EXPECT_VALID(lib); | |
422 } | |
423 CompilerStats* stats = Isolate::Current()->compiler_stats(); | |
424 ASSERT(stats != NULL); | |
425 stats->EnableBenchmark(); | |
426 Timer timer(true, "Compile all of dart2js benchmark"); | |
427 timer.Start(); | |
428 Dart_Handle result = Dart_CompileAll(); | |
429 EXPECT_VALID(result); | |
430 timer.Stop(); | |
431 int64_t elapsed_time = timer.TotalElapsedTime(); | |
432 benchmark->set_score(elapsed_time); | |
433 free(dart_root); | |
434 free(script); | |
435 } | |
436 | |
437 | |
381 // | 438 // |
382 // Measure frame lookup during stack traversal. | 439 // Measure frame lookup during stack traversal. |
383 // | 440 // |
384 static void StackFrame_accessFrame(Dart_NativeArguments args) { | 441 static void StackFrame_accessFrame(Dart_NativeArguments args) { |
385 const int kNumIterations = 100; | 442 const int kNumIterations = 100; |
386 Code& code = Code::Handle(); | 443 Code& code = Code::Handle(); |
387 Timer timer(true, "LookupDartCode benchmark"); | 444 Timer timer(true, "LookupDartCode benchmark"); |
388 timer.Start(); | 445 timer.Start(); |
389 for (int i = 0; i < kNumIterations; i++) { | 446 for (int i = 0; i < kNumIterations; i++) { |
390 StackFrameIterator frames(StackFrameIterator::kDontValidateFrames); | 447 StackFrameIterator frames(StackFrameIterator::kDontValidateFrames); |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
695 thread); | 752 thread); |
696 reader.ReadObject(); | 753 reader.ReadObject(); |
697 free(buffer); | 754 free(buffer); |
698 } | 755 } |
699 timer.Stop(); | 756 timer.Stop(); |
700 int64_t elapsed_time = timer.TotalElapsedTime(); | 757 int64_t elapsed_time = timer.TotalElapsedTime(); |
701 benchmark->set_score(elapsed_time); | 758 benchmark->set_score(elapsed_time); |
702 } | 759 } |
703 | 760 |
704 } // namespace dart | 761 } // namespace dart |
OLD | NEW |