| 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" |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 Api::CheckIsolateState(Isolate::Current()); | 448 Api::CheckIsolateState(Isolate::Current()); |
| 449 | 449 |
| 450 // Write snapshot with object content. | 450 // Write snapshot with object content. |
| 451 FullSnapshotWriter writer(&buffer, &malloc_allocator); | 451 FullSnapshotWriter writer(&buffer, &malloc_allocator); |
| 452 writer.WriteFullSnapshot(); | 452 writer.WriteFullSnapshot(); |
| 453 const Snapshot* snapshot = Snapshot::SetupFromBuffer(buffer); | 453 const Snapshot* snapshot = Snapshot::SetupFromBuffer(buffer); |
| 454 ASSERT(snapshot->kind() == Snapshot::kFull); | 454 ASSERT(snapshot->kind() == Snapshot::kFull); |
| 455 benchmark->set_score(snapshot->length()); | 455 benchmark->set_score(snapshot->length()); |
| 456 } | 456 } |
| 457 | 457 |
| 458 |
| 459 BENCHMARK(CreateMirrorSystem) { |
| 460 const char* kScriptChars = |
| 461 "import 'dart:mirrors';\n" |
| 462 "\n" |
| 463 "void benchmark() {\n" |
| 464 " currentMirrorSystem();\n" |
| 465 "}\n"; |
| 466 |
| 467 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); |
| 468 Dart_Handle args[0]; |
| 469 |
| 470 Timer timer(true, "currentMirrorSystem() benchmark"); |
| 471 timer.Start(); |
| 472 Dart_Invoke(lib, NewString("benchmark"), 0, args); |
| 473 timer.Stop(); |
| 474 int64_t elapsed_time = timer.TotalElapsedTime(); |
| 475 benchmark->set_score(elapsed_time); |
| 476 } |
| 477 |
| 458 } // namespace dart | 478 } // namespace dart |
| OLD | NEW |