| 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/file.h" | 7 #include "bin/file.h" |
| 8 | 8 |
| 9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
| 10 | 10 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 #endif // TARGET_ARCH_IA32 || TARGET_ARCH_X64 | 49 #endif // TARGET_ARCH_IA32 || TARGET_ARCH_X64 |
| 50 | 50 |
| 51 | 51 |
| 52 // | 52 // |
| 53 // Measure creation of core isolate from a snapshot. | 53 // Measure creation of core isolate from a snapshot. |
| 54 // | 54 // |
| 55 BENCHMARK(CorelibIsolateStartup) { | 55 BENCHMARK(CorelibIsolateStartup) { |
| 56 const int kNumIterations = 100; | 56 const int kNumIterations = 100; |
| 57 char* err = NULL; | 57 char* err = NULL; |
| 58 Dart_Isolate base_isolate = Dart_CurrentIsolate(); | 58 Dart_Isolate base_isolate = Dart_CurrentIsolate(); |
| 59 Dart_Isolate test_isolate = Dart_CreateIsolate(NULL, NULL, NULL, NULL, &err); | 59 Dart_Isolate test_isolate = Dart_CreateIsolate(NULL, NULL, NULL, &err); |
| 60 EXPECT(test_isolate != NULL); | 60 EXPECT(test_isolate != NULL); |
| 61 Dart_EnterScope(); | 61 Dart_EnterScope(); |
| 62 uint8_t* buffer = NULL; | 62 uint8_t* buffer = NULL; |
| 63 intptr_t size = 0; | 63 intptr_t size = 0; |
| 64 Dart_Handle result = Dart_CreateSnapshot(&buffer, &size); | 64 Dart_Handle result = Dart_CreateSnapshot(&buffer, &size); |
| 65 EXPECT(!Dart_IsError(result)); | 65 EXPECT(!Dart_IsError(result)); |
| 66 Timer timer(true, "Core Isolate startup benchmark"); | 66 Timer timer(true, "Core Isolate startup benchmark"); |
| 67 timer.Start(); | 67 timer.Start(); |
| 68 for (int i = 0; i < kNumIterations; i++) { | 68 for (int i = 0; i < kNumIterations; i++) { |
| 69 Dart_Isolate new_isolate = | 69 Dart_Isolate new_isolate = Dart_CreateIsolate(NULL, buffer, NULL, &err); |
| 70 Dart_CreateIsolate(NULL, NULL, buffer, NULL, &err); | |
| 71 EXPECT(new_isolate != NULL); | 70 EXPECT(new_isolate != NULL); |
| 72 Dart_ShutdownIsolate(); | 71 Dart_ShutdownIsolate(); |
| 73 } | 72 } |
| 74 timer.Stop(); | 73 timer.Stop(); |
| 75 int64_t elapsed_time = timer.TotalElapsedTime(); | 74 int64_t elapsed_time = timer.TotalElapsedTime(); |
| 76 benchmark->set_score(elapsed_time / kNumIterations); | 75 benchmark->set_score(elapsed_time / kNumIterations); |
| 77 Dart_EnterIsolate(test_isolate); | 76 Dart_EnterIsolate(test_isolate); |
| 78 Dart_ExitScope(); | 77 Dart_ExitScope(); |
| 79 Dart_ShutdownIsolate(); | 78 Dart_ShutdownIsolate(); |
| 80 Dart_EnterIsolate(base_isolate); | 79 Dart_EnterIsolate(base_isolate); |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 reinterpret_cast<Dart_NativeEntryResolver>(StackFrameNativeResolver)); | 335 reinterpret_cast<Dart_NativeEntryResolver>(StackFrameNativeResolver)); |
| 337 Dart_Handle cls = Dart_GetClass(lib, Dart_NewString("StackFrameTest")); | 336 Dart_Handle cls = Dart_GetClass(lib, Dart_NewString("StackFrameTest")); |
| 338 Dart_Handle result = Dart_Invoke(cls, Dart_NewString("testMain"), 0, NULL); | 337 Dart_Handle result = Dart_Invoke(cls, Dart_NewString("testMain"), 0, NULL); |
| 339 EXPECT_VALID(result); | 338 EXPECT_VALID(result); |
| 340 int64_t elapsed_time = 0; | 339 int64_t elapsed_time = 0; |
| 341 EXPECT(!Dart_IsError(Dart_IntegerToInt64(result, &elapsed_time))); | 340 EXPECT(!Dart_IsError(Dart_IntegerToInt64(result, &elapsed_time))); |
| 342 benchmark->set_score(elapsed_time); | 341 benchmark->set_score(elapsed_time); |
| 343 } | 342 } |
| 344 | 343 |
| 345 } // namespace dart | 344 } // namespace dart |
| OLD | NEW |