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 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
431 "import 'dart:collection';\n" | 431 "import 'dart:collection';\n" |
432 "import 'dart:_internal';\n" | 432 "import 'dart:_internal';\n" |
433 "import 'dart:math';\n" | 433 "import 'dart:math';\n" |
434 "import 'dart:isolate';\n" | 434 "import 'dart:isolate';\n" |
435 "import 'dart:mirrors';\n" | 435 "import 'dart:mirrors';\n" |
436 "import 'dart:typed_data';\n" | 436 "import 'dart:typed_data';\n" |
437 "\n"; | 437 "\n"; |
438 | 438 |
439 // Start an Isolate, load a script and create a full snapshot. | 439 // Start an Isolate, load a script and create a full snapshot. |
440 uint8_t* buffer; | 440 uint8_t* buffer; |
441 TestCase::LoadTestScript(kScriptChars, NULL); | 441 TestCase::LoadCoreTestScript(kScriptChars, NULL); |
Ivan Posva
2014/05/09 06:31:35
Please add a comment explaining why LoadCoreTestSc
hausner
2014/05/09 17:07:18
Done. Yes, it's because importing dart:_internal c
| |
442 Api::CheckIsolateState(Isolate::Current()); | 442 Api::CheckIsolateState(Isolate::Current()); |
443 | 443 |
444 // Write snapshot with object content. | 444 // Write snapshot with object content. |
445 FullSnapshotWriter writer(&buffer, &malloc_allocator); | 445 FullSnapshotWriter writer(&buffer, &malloc_allocator); |
446 writer.WriteFullSnapshot(); | 446 writer.WriteFullSnapshot(); |
447 const Snapshot* snapshot = Snapshot::SetupFromBuffer(buffer); | 447 const Snapshot* snapshot = Snapshot::SetupFromBuffer(buffer); |
448 ASSERT(snapshot->kind() == Snapshot::kFull); | 448 ASSERT(snapshot->kind() == Snapshot::kFull); |
449 benchmark->set_score(snapshot->length()); | 449 benchmark->set_score(snapshot->length()); |
450 } | 450 } |
451 | 451 |
452 | 452 |
453 BENCHMARK(StandaloneSnapshotSize) { | 453 BENCHMARK(StandaloneSnapshotSize) { |
454 const char* kScriptChars = | 454 const char* kScriptChars = |
455 "import 'dart:async';\n" | 455 "import 'dart:async';\n" |
456 "import 'dart:core';\n" | 456 "import 'dart:core';\n" |
457 "import 'dart:collection';\n" | 457 "import 'dart:collection';\n" |
458 "import 'dart:_internal';\n" | 458 "import 'dart:_internal';\n" |
459 "import 'dart:convert';\n" | 459 "import 'dart:convert';\n" |
460 "import 'dart:math';\n" | 460 "import 'dart:math';\n" |
461 "import 'dart:isolate';\n" | 461 "import 'dart:isolate';\n" |
462 "import 'dart:mirrors';\n" | 462 "import 'dart:mirrors';\n" |
463 "import 'dart:typed_data';\n" | 463 "import 'dart:typed_data';\n" |
464 "import 'dart:builtin';\n" | 464 "import 'dart:builtin';\n" |
465 "import 'dart:io';\n" | 465 "import 'dart:io';\n" |
466 "\n"; | 466 "\n"; |
467 | 467 |
468 // Start an Isolate, load a script and create a full snapshot. | 468 // Start an Isolate, load a script and create a full snapshot. |
469 uint8_t* buffer; | 469 uint8_t* buffer; |
470 TestCase::LoadTestScript(kScriptChars, NULL); | 470 TestCase::LoadCoreTestScript(kScriptChars, NULL); |
Ivan Posva
2014/05/09 06:31:35
ditto
hausner
2014/05/09 17:07:18
Done.
| |
471 Api::CheckIsolateState(Isolate::Current()); | 471 Api::CheckIsolateState(Isolate::Current()); |
472 | 472 |
473 // Write snapshot with object content. | 473 // Write snapshot with object content. |
474 FullSnapshotWriter writer(&buffer, &malloc_allocator); | 474 FullSnapshotWriter writer(&buffer, &malloc_allocator); |
475 writer.WriteFullSnapshot(); | 475 writer.WriteFullSnapshot(); |
476 const Snapshot* snapshot = Snapshot::SetupFromBuffer(buffer); | 476 const Snapshot* snapshot = Snapshot::SetupFromBuffer(buffer); |
477 ASSERT(snapshot->kind() == Snapshot::kFull); | 477 ASSERT(snapshot->kind() == Snapshot::kFull); |
478 benchmark->set_score(snapshot->length()); | 478 benchmark->set_score(snapshot->length()); |
479 } | 479 } |
480 | 480 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
587 SnapshotReader reader(buffer, buffer_len, Snapshot::kMessage, isolate); | 587 SnapshotReader reader(buffer, buffer_len, Snapshot::kMessage, isolate); |
588 reader.ReadObject(); | 588 reader.ReadObject(); |
589 free(buffer); | 589 free(buffer); |
590 } | 590 } |
591 timer.Stop(); | 591 timer.Stop(); |
592 int64_t elapsed_time = timer.TotalElapsedTime(); | 592 int64_t elapsed_time = timer.TotalElapsedTime(); |
593 benchmark->set_score(elapsed_time); | 593 benchmark->set_score(elapsed_time); |
594 } | 594 } |
595 | 595 |
596 } // namespace dart | 596 } // namespace dart |
OLD | NEW |