| 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/file.h" | 7 #include "bin/file.h" |
| 8 | 8 |
| 9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
| 10 | 10 |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 | 393 |
| 394 BENCHMARK(CoreSnapshotSize) { | 394 BENCHMARK(CoreSnapshotSize) { |
| 395 const char* kScriptChars = | 395 const char* kScriptChars = |
| 396 "import 'dart:async';\n" | 396 "import 'dart:async';\n" |
| 397 "import 'dart:core';\n" | 397 "import 'dart:core';\n" |
| 398 "import 'dart:collection';\n" | 398 "import 'dart:collection';\n" |
| 399 "import 'dart:_collection-dev';\n" | 399 "import 'dart:_collection-dev';\n" |
| 400 "import 'dart:math';\n" | 400 "import 'dart:math';\n" |
| 401 "import 'dart:isolate';\n" | 401 "import 'dart:isolate';\n" |
| 402 "import 'dart:mirrors';\n" | 402 "import 'dart:mirrors';\n" |
| 403 "import 'dart:typeddata';\n" | 403 "import 'dart:typed_data';\n" |
| 404 "\n"; | 404 "\n"; |
| 405 | 405 |
| 406 // Start an Isolate, load a script and create a full snapshot. | 406 // Start an Isolate, load a script and create a full snapshot. |
| 407 uint8_t* buffer; | 407 uint8_t* buffer; |
| 408 TestCase::LoadTestScript(kScriptChars, NULL); | 408 TestCase::LoadTestScript(kScriptChars, NULL); |
| 409 Api::CheckIsolateState(Isolate::Current()); | 409 Api::CheckIsolateState(Isolate::Current()); |
| 410 | 410 |
| 411 // Write snapshot with object content. | 411 // Write snapshot with object content. |
| 412 FullSnapshotWriter writer(&buffer, &malloc_allocator); | 412 FullSnapshotWriter writer(&buffer, &malloc_allocator); |
| 413 writer.WriteFullSnapshot(); | 413 writer.WriteFullSnapshot(); |
| 414 const Snapshot* snapshot = Snapshot::SetupFromBuffer(buffer); | 414 const Snapshot* snapshot = Snapshot::SetupFromBuffer(buffer); |
| 415 ASSERT(snapshot->kind() == Snapshot::kFull); | 415 ASSERT(snapshot->kind() == Snapshot::kFull); |
| 416 benchmark->set_score(snapshot->length()); | 416 benchmark->set_score(snapshot->length()); |
| 417 } | 417 } |
| 418 | 418 |
| 419 | 419 |
| 420 BENCHMARK(StandaloneSnapshotSize) { | 420 BENCHMARK(StandaloneSnapshotSize) { |
| 421 const char* kScriptChars = | 421 const char* kScriptChars = |
| 422 "import 'dart:async';\n" | 422 "import 'dart:async';\n" |
| 423 "import 'dart:core';\n" | 423 "import 'dart:core';\n" |
| 424 "import 'dart:collection';\n" | 424 "import 'dart:collection';\n" |
| 425 "import 'dart:_collection-dev';\n" | 425 "import 'dart:_collection-dev';\n" |
| 426 "import 'dart:math';\n" | 426 "import 'dart:math';\n" |
| 427 "import 'dart:isolate';\n" | 427 "import 'dart:isolate';\n" |
| 428 "import 'dart:mirrors';\n" | 428 "import 'dart:mirrors';\n" |
| 429 "import 'dart:typeddata';\n" | 429 "import 'dart:typed_data';\n" |
| 430 "import 'dart:uri';\n" | 430 "import 'dart:uri';\n" |
| 431 "import 'dart:utf';\n" | 431 "import 'dart:utf';\n" |
| 432 "import 'dart:json';\n" | 432 "import 'dart:json';\n" |
| 433 "import 'dart:crypto';\n" | 433 "import 'dart:crypto';\n" |
| 434 "import 'dart:builtin';\n" | 434 "import 'dart:builtin';\n" |
| 435 "import 'dart:io';\n" | 435 "import 'dart:io';\n" |
| 436 "\n"; | 436 "\n"; |
| 437 | 437 |
| 438 // Start an Isolate, load a script and create a full snapshot. | 438 // Start an Isolate, load a script and create a full snapshot. |
| 439 uint8_t* buffer; | 439 uint8_t* buffer; |
| 440 TestCase::LoadTestScript(kScriptChars, NULL); | 440 TestCase::LoadTestScript(kScriptChars, NULL); |
| 441 Api::CheckIsolateState(Isolate::Current()); | 441 Api::CheckIsolateState(Isolate::Current()); |
| 442 | 442 |
| 443 // Write snapshot with object content. | 443 // Write snapshot with object content. |
| 444 FullSnapshotWriter writer(&buffer, &malloc_allocator); | 444 FullSnapshotWriter writer(&buffer, &malloc_allocator); |
| 445 writer.WriteFullSnapshot(); | 445 writer.WriteFullSnapshot(); |
| 446 const Snapshot* snapshot = Snapshot::SetupFromBuffer(buffer); | 446 const Snapshot* snapshot = Snapshot::SetupFromBuffer(buffer); |
| 447 ASSERT(snapshot->kind() == Snapshot::kFull); | 447 ASSERT(snapshot->kind() == Snapshot::kFull); |
| 448 benchmark->set_score(snapshot->length()); | 448 benchmark->set_score(snapshot->length()); |
| 449 } | 449 } |
| 450 | 450 |
| 451 } // namespace dart | 451 } // namespace dart |
| OLD | NEW |