Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 #include "vm/benchmark_test.h" | |
| 6 #include "vm/dart_api_impl.h" | |
| 7 | |
| 8 namespace dart { | |
| 9 | |
| 10 Benchmark* Benchmark::first_ = NULL; | |
| 11 Benchmark* Benchmark::tail_ = NULL; | |
| 12 | |
| 13 void Benchmark::RunAll() { | |
| 14 Benchmark* benchmark = first_; | |
| 15 while (benchmark != NULL) { | |
| 16 benchmark->RunBenchmark(); | |
| 17 benchmark = benchmark->next_; | |
| 18 } | |
| 19 } | |
| 20 | |
| 21 | |
| 22 // Compiler only implemented on IA32 and X64 now. | |
| 23 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) | |
| 24 | |
| 25 BENCHMARK(CorelibCompileAll) { | |
| 26 Timer timer(true, "Compile all benchmark"); | |
| 27 timer.Start(); | |
| 28 const Error& error = Error::Handle(benchmark->isolate(), | |
| 29 Library::CompileAll()); | |
| 30 EXPECT(error.IsNull()); | |
| 31 timer.Stop(); | |
| 32 int64_t elapsed_time = timer.TotalElapsedTime(); | |
| 33 benchmark->set_score(elapsed_time); | |
| 34 } | |
| 35 | |
| 36 #endif // TARGET_ARCH_IA32 || TARGET_ARCH_X64 | |
| 37 | |
| 38 | |
| 39 BENCHMARK(CorelibIsolateStartup) { | |
| 40 const int kNumIterations = 100; | |
| 41 char* err; | |
|
srdjan
2012/04/20 23:13:55
initialize to NULL?
siva
2012/04/30 16:38:04
Done.
| |
| 42 Dart_Isolate base_isolate = Dart_CurrentIsolate(); | |
| 43 Dart_Isolate test_isolate = Dart_CreateIsolate(NULL, NULL, NULL, &err); | |
| 44 EXPECT(test_isolate != NULL); | |
| 45 Dart_EnterScope(); | |
| 46 uint8_t* buffer = NULL; | |
| 47 intptr_t size = 0; | |
| 48 Dart_Handle result = Dart_CreateSnapshot(&buffer, &size); | |
| 49 EXPECT(!Dart_IsError(result)); | |
| 50 Timer timer(true, "Core Isolate startup benchmark"); | |
| 51 timer.Start(); | |
| 52 for (int i = 0; i < kNumIterations; i++) { | |
| 53 Dart_Isolate new_isolate = Dart_CreateIsolate(NULL, buffer, NULL, &err); | |
| 54 EXPECT(new_isolate != NULL); | |
| 55 Dart_ShutdownIsolate(); | |
| 56 } | |
| 57 timer.Stop(); | |
| 58 Dart_EnterIsolate(test_isolate); | |
| 59 Dart_ExitScope(); | |
| 60 Dart_ShutdownIsolate(); | |
| 61 Dart_EnterIsolate(base_isolate); | |
| 62 int64_t elapsed_time = timer.TotalElapsedTime(); | |
| 63 benchmark->set_score(elapsed_time / kNumIterations); | |
| 64 } | |
| 65 | |
| 66 } // namespace dart | |
| OLD | NEW |