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 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 "import 'dart:core';\n" | 421 "import 'dart:core';\n" |
422 "import 'dart:collection';\n" | 422 "import 'dart:collection';\n" |
423 "import 'dart:_internal';\n" | 423 "import 'dart:_internal';\n" |
424 "import 'dart:math';\n" | 424 "import 'dart:math';\n" |
425 "import 'dart:isolate';\n" | 425 "import 'dart:isolate';\n" |
426 "import 'dart:mirrors';\n" | 426 "import 'dart:mirrors';\n" |
427 "import 'dart:typed_data';\n" | 427 "import 'dart:typed_data';\n" |
428 "\n"; | 428 "\n"; |
429 | 429 |
430 // Start an Isolate, load a script and create a full snapshot. | 430 // Start an Isolate, load a script and create a full snapshot. |
431 uint8_t* buffer; | 431 uint8_t* vm_isolate_snapshot_buffer; |
| 432 uint8_t* isolate_snapshot_buffer; |
432 // Need to load the script into the dart: core library due to | 433 // Need to load the script into the dart: core library due to |
433 // the import of dart:_internal. | 434 // the import of dart:_internal. |
434 TestCase::LoadCoreTestScript(kScriptChars, NULL); | 435 TestCase::LoadCoreTestScript(kScriptChars, NULL); |
435 Api::CheckAndFinalizePendingClasses(Isolate::Current()); | 436 Api::CheckAndFinalizePendingClasses(Isolate::Current()); |
436 | 437 |
437 // Write snapshot with object content. | 438 // Write snapshot with object content. |
438 FullSnapshotWriter writer(&buffer, &malloc_allocator); | 439 FullSnapshotWriter writer(&vm_isolate_snapshot_buffer, |
| 440 &isolate_snapshot_buffer, |
| 441 &malloc_allocator); |
439 writer.WriteFullSnapshot(); | 442 writer.WriteFullSnapshot(); |
440 const Snapshot* snapshot = Snapshot::SetupFromBuffer(buffer); | 443 const Snapshot* snapshot = Snapshot::SetupFromBuffer(isolate_snapshot_buffer); |
441 ASSERT(snapshot->kind() == Snapshot::kFull); | 444 ASSERT(snapshot->kind() == Snapshot::kFull); |
442 benchmark->set_score(snapshot->length()); | 445 benchmark->set_score(snapshot->length()); |
443 } | 446 } |
444 | 447 |
445 | 448 |
446 BENCHMARK_SIZE(StandaloneSnapshotSize) { | 449 BENCHMARK_SIZE(StandaloneSnapshotSize) { |
447 const char* kScriptChars = | 450 const char* kScriptChars = |
448 "import 'dart:async';\n" | 451 "import 'dart:async';\n" |
449 "import 'dart:core';\n" | 452 "import 'dart:core';\n" |
450 "import 'dart:collection';\n" | 453 "import 'dart:collection';\n" |
451 "import 'dart:_internal';\n" | 454 "import 'dart:_internal';\n" |
452 "import 'dart:convert';\n" | 455 "import 'dart:convert';\n" |
453 "import 'dart:math';\n" | 456 "import 'dart:math';\n" |
454 "import 'dart:isolate';\n" | 457 "import 'dart:isolate';\n" |
455 "import 'dart:mirrors';\n" | 458 "import 'dart:mirrors';\n" |
456 "import 'dart:typed_data';\n" | 459 "import 'dart:typed_data';\n" |
457 "import 'dart:_builtin';\n" | 460 "import 'dart:_builtin';\n" |
458 "import 'dart:io';\n" | 461 "import 'dart:io';\n" |
459 "\n"; | 462 "\n"; |
460 | 463 |
461 // Start an Isolate, load a script and create a full snapshot. | 464 // Start an Isolate, load a script and create a full snapshot. |
462 uint8_t* buffer; | 465 uint8_t* vm_isolate_snapshot_buffer; |
| 466 uint8_t* isolate_snapshot_buffer; |
463 // Need to load the script into the dart: core library due to | 467 // Need to load the script into the dart: core library due to |
464 // the import of dart:_internal. | 468 // the import of dart:_internal. |
465 TestCase::LoadCoreTestScript(kScriptChars, NULL); | 469 TestCase::LoadCoreTestScript(kScriptChars, NULL); |
466 Api::CheckAndFinalizePendingClasses(Isolate::Current()); | 470 Api::CheckAndFinalizePendingClasses(Isolate::Current()); |
467 | 471 |
468 // Write snapshot with object content. | 472 // Write snapshot with object content. |
469 FullSnapshotWriter writer(&buffer, &malloc_allocator); | 473 FullSnapshotWriter writer(&vm_isolate_snapshot_buffer, |
| 474 &isolate_snapshot_buffer, |
| 475 &malloc_allocator); |
470 writer.WriteFullSnapshot(); | 476 writer.WriteFullSnapshot(); |
471 const Snapshot* snapshot = Snapshot::SetupFromBuffer(buffer); | 477 const Snapshot* snapshot = Snapshot::SetupFromBuffer(isolate_snapshot_buffer); |
472 ASSERT(snapshot->kind() == Snapshot::kFull); | 478 ASSERT(snapshot->kind() == Snapshot::kFull); |
473 benchmark->set_score(snapshot->length()); | 479 benchmark->set_score(snapshot->length()); |
474 } | 480 } |
475 | 481 |
476 | 482 |
477 BENCHMARK(CreateMirrorSystem) { | 483 BENCHMARK(CreateMirrorSystem) { |
478 const char* kScriptChars = | 484 const char* kScriptChars = |
479 "import 'dart:mirrors';\n" | 485 "import 'dart:mirrors';\n" |
480 "\n" | 486 "\n" |
481 "void benchmark() {\n" | 487 "void benchmark() {\n" |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 zone.GetZone()); | 594 zone.GetZone()); |
589 reader.ReadObject(); | 595 reader.ReadObject(); |
590 free(buffer); | 596 free(buffer); |
591 } | 597 } |
592 timer.Stop(); | 598 timer.Stop(); |
593 int64_t elapsed_time = timer.TotalElapsedTime(); | 599 int64_t elapsed_time = timer.TotalElapsedTime(); |
594 benchmark->set_score(elapsed_time); | 600 benchmark->set_score(elapsed_time); |
595 } | 601 } |
596 | 602 |
597 } // namespace dart | 603 } // namespace dart |
OLD | NEW |