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 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 uint8_t* ptr, intptr_t old_size, intptr_t new_size) { | 407 uint8_t* ptr, intptr_t old_size, intptr_t new_size) { |
408 return reinterpret_cast<uint8_t*>(realloc(ptr, new_size)); | 408 return reinterpret_cast<uint8_t*>(realloc(ptr, new_size)); |
409 } | 409 } |
410 | 410 |
411 | 411 |
412 BENCHMARK(CoreSnapshotSize) { | 412 BENCHMARK(CoreSnapshotSize) { |
413 const char* kScriptChars = | 413 const char* kScriptChars = |
414 "import 'dart:async';\n" | 414 "import 'dart:async';\n" |
415 "import 'dart:core';\n" | 415 "import 'dart:core';\n" |
416 "import 'dart:collection';\n" | 416 "import 'dart:collection';\n" |
417 "import 'dart:_collection-dev';\n" | 417 "import 'dart:_internal';\n" |
418 "import 'dart:math';\n" | 418 "import 'dart:math';\n" |
419 "import 'dart:isolate';\n" | 419 "import 'dart:isolate';\n" |
420 "import 'dart:mirrors';\n" | 420 "import 'dart:mirrors';\n" |
421 "import 'dart:typed_data';\n" | 421 "import 'dart:typed_data';\n" |
422 "\n"; | 422 "\n"; |
423 | 423 |
424 // Start an Isolate, load a script and create a full snapshot. | 424 // Start an Isolate, load a script and create a full snapshot. |
425 uint8_t* buffer; | 425 uint8_t* buffer; |
426 TestCase::LoadTestScript(kScriptChars, NULL); | 426 TestCase::LoadTestScript(kScriptChars, NULL); |
427 Api::CheckIsolateState(Isolate::Current()); | 427 Api::CheckIsolateState(Isolate::Current()); |
428 | 428 |
429 // Write snapshot with object content. | 429 // Write snapshot with object content. |
430 FullSnapshotWriter writer(&buffer, &malloc_allocator); | 430 FullSnapshotWriter writer(&buffer, &malloc_allocator); |
431 writer.WriteFullSnapshot(); | 431 writer.WriteFullSnapshot(); |
432 const Snapshot* snapshot = Snapshot::SetupFromBuffer(buffer); | 432 const Snapshot* snapshot = Snapshot::SetupFromBuffer(buffer); |
433 ASSERT(snapshot->kind() == Snapshot::kFull); | 433 ASSERT(snapshot->kind() == Snapshot::kFull); |
434 benchmark->set_score(snapshot->length()); | 434 benchmark->set_score(snapshot->length()); |
435 } | 435 } |
436 | 436 |
437 | 437 |
438 BENCHMARK(StandaloneSnapshotSize) { | 438 BENCHMARK(StandaloneSnapshotSize) { |
439 const char* kScriptChars = | 439 const char* kScriptChars = |
440 "import 'dart:async';\n" | 440 "import 'dart:async';\n" |
441 "import 'dart:core';\n" | 441 "import 'dart:core';\n" |
442 "import 'dart:collection';\n" | 442 "import 'dart:collection';\n" |
443 "import 'dart:_collection-dev';\n" | 443 "import 'dart:_internal';\n" |
444 "import 'dart:convert';\n" | 444 "import 'dart:convert';\n" |
445 "import 'dart:math';\n" | 445 "import 'dart:math';\n" |
446 "import 'dart:isolate';\n" | 446 "import 'dart:isolate';\n" |
447 "import 'dart:mirrors';\n" | 447 "import 'dart:mirrors';\n" |
448 "import 'dart:typed_data';\n" | 448 "import 'dart:typed_data';\n" |
449 "import 'dart:builtin';\n" | 449 "import 'dart:builtin';\n" |
450 "import 'dart:io';\n" | 450 "import 'dart:io';\n" |
451 "\n"; | 451 "\n"; |
452 | 452 |
453 // Start an Isolate, load a script and create a full snapshot. | 453 // Start an Isolate, load a script and create a full snapshot. |
(...skipping 22 matching lines...) Expand all Loading... |
476 | 476 |
477 Timer timer(true, "currentMirrorSystem() benchmark"); | 477 Timer timer(true, "currentMirrorSystem() benchmark"); |
478 timer.Start(); | 478 timer.Start(); |
479 Dart_Invoke(lib, NewString("benchmark"), 0, NULL); | 479 Dart_Invoke(lib, NewString("benchmark"), 0, NULL); |
480 timer.Stop(); | 480 timer.Stop(); |
481 int64_t elapsed_time = timer.TotalElapsedTime(); | 481 int64_t elapsed_time = timer.TotalElapsedTime(); |
482 benchmark->set_score(elapsed_time); | 482 benchmark->set_score(elapsed_time); |
483 } | 483 } |
484 | 484 |
485 } // namespace dart | 485 } // namespace dart |
OLD | NEW |