| 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 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 benchmark->set_score(elapsed_time); | 387 benchmark->set_score(elapsed_time); |
| 388 } | 388 } |
| 389 | 389 |
| 390 | 390 |
| 391 static uint8_t* malloc_allocator( | 391 static uint8_t* malloc_allocator( |
| 392 uint8_t* ptr, intptr_t old_size, intptr_t new_size) { | 392 uint8_t* ptr, intptr_t old_size, intptr_t new_size) { |
| 393 return reinterpret_cast<uint8_t*>(realloc(ptr, new_size)); | 393 return reinterpret_cast<uint8_t*>(realloc(ptr, new_size)); |
| 394 } | 394 } |
| 395 | 395 |
| 396 | 396 |
| 397 BENCHMARK(CoreSnapshotSize) { | 397 BENCHMARK_SIZE(CoreSnapshotSize) { |
| 398 const char* kScriptChars = | 398 const char* kScriptChars = |
| 399 "import 'dart:async';\n" | 399 "import 'dart:async';\n" |
| 400 "import 'dart:core';\n" | 400 "import 'dart:core';\n" |
| 401 "import 'dart:collection';\n" | 401 "import 'dart:collection';\n" |
| 402 "import 'dart:_internal';\n" | 402 "import 'dart:_internal';\n" |
| 403 "import 'dart:math';\n" | 403 "import 'dart:math';\n" |
| 404 "import 'dart:isolate';\n" | 404 "import 'dart:isolate';\n" |
| 405 "import 'dart:mirrors';\n" | 405 "import 'dart:mirrors';\n" |
| 406 "import 'dart:typed_data';\n" | 406 "import 'dart:typed_data';\n" |
| 407 "\n"; | 407 "\n"; |
| 408 | 408 |
| 409 // Start an Isolate, load a script and create a full snapshot. | 409 // Start an Isolate, load a script and create a full snapshot. |
| 410 uint8_t* buffer; | 410 uint8_t* buffer; |
| 411 // Need to load the script into the dart: core library due to | 411 // Need to load the script into the dart: core library due to |
| 412 // the import of dart:_internal. | 412 // the import of dart:_internal. |
| 413 TestCase::LoadCoreTestScript(kScriptChars, NULL); | 413 TestCase::LoadCoreTestScript(kScriptChars, NULL); |
| 414 Api::CheckIsolateState(Isolate::Current()); | 414 Api::CheckIsolateState(Isolate::Current()); |
| 415 | 415 |
| 416 // Write snapshot with object content. | 416 // Write snapshot with object content. |
| 417 FullSnapshotWriter writer(&buffer, &malloc_allocator); | 417 FullSnapshotWriter writer(&buffer, &malloc_allocator); |
| 418 writer.WriteFullSnapshot(); | 418 writer.WriteFullSnapshot(); |
| 419 const Snapshot* snapshot = Snapshot::SetupFromBuffer(buffer); | 419 const Snapshot* snapshot = Snapshot::SetupFromBuffer(buffer); |
| 420 ASSERT(snapshot->kind() == Snapshot::kFull); | 420 ASSERT(snapshot->kind() == Snapshot::kFull); |
| 421 benchmark->set_score(snapshot->length()); | 421 benchmark->set_score(snapshot->length()); |
| 422 } | 422 } |
| 423 | 423 |
| 424 | 424 |
| 425 BENCHMARK(StandaloneSnapshotSize) { | 425 BENCHMARK_SIZE(StandaloneSnapshotSize) { |
| 426 const char* kScriptChars = | 426 const char* kScriptChars = |
| 427 "import 'dart:async';\n" | 427 "import 'dart:async';\n" |
| 428 "import 'dart:core';\n" | 428 "import 'dart:core';\n" |
| 429 "import 'dart:collection';\n" | 429 "import 'dart:collection';\n" |
| 430 "import 'dart:_internal';\n" | 430 "import 'dart:_internal';\n" |
| 431 "import 'dart:convert';\n" | 431 "import 'dart:convert';\n" |
| 432 "import 'dart:math';\n" | 432 "import 'dart:math';\n" |
| 433 "import 'dart:isolate';\n" | 433 "import 'dart:isolate';\n" |
| 434 "import 'dart:mirrors';\n" | 434 "import 'dart:mirrors';\n" |
| 435 "import 'dart:typed_data';\n" | 435 "import 'dart:typed_data';\n" |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 SnapshotReader reader(buffer, buffer_len, Snapshot::kMessage, isolate); | 561 SnapshotReader reader(buffer, buffer_len, Snapshot::kMessage, isolate); |
| 562 reader.ReadObject(); | 562 reader.ReadObject(); |
| 563 free(buffer); | 563 free(buffer); |
| 564 } | 564 } |
| 565 timer.Stop(); | 565 timer.Stop(); |
| 566 int64_t elapsed_time = timer.TotalElapsedTime(); | 566 int64_t elapsed_time = timer.TotalElapsedTime(); |
| 567 benchmark->set_score(elapsed_time); | 567 benchmark->set_score(elapsed_time); |
| 568 } | 568 } |
| 569 | 569 |
| 570 } // namespace dart | 570 } // namespace dart |
| OLD | NEW |