| 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 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 isolate, | 600 isolate, |
| 601 zone.GetZone()); | 601 zone.GetZone()); |
| 602 reader.ReadObject(); | 602 reader.ReadObject(); |
| 603 free(buffer); | 603 free(buffer); |
| 604 } | 604 } |
| 605 timer.Stop(); | 605 timer.Stop(); |
| 606 int64_t elapsed_time = timer.TotalElapsedTime(); | 606 int64_t elapsed_time = timer.TotalElapsedTime(); |
| 607 benchmark->set_score(elapsed_time); | 607 benchmark->set_score(elapsed_time); |
| 608 } | 608 } |
| 609 | 609 |
| 610 |
| 611 BENCHMARK(LargeMap) { |
| 612 const char* kScript = |
| 613 "makeMap() {\n" |
| 614 " Map m = {};\n" |
| 615 " for (int i = 0; i < 100000; ++i) m[i*13+i*(i>>7)] = i;\n" |
| 616 " return m;\n" |
| 617 "}"; |
| 618 Dart_Handle h_lib = TestCase::LoadTestScript(kScript, NULL); |
| 619 EXPECT_VALID(h_lib); |
| 620 Dart_Handle h_result = Dart_Invoke(h_lib, NewString("makeMap"), 0, NULL); |
| 621 EXPECT_VALID(h_result); |
| 622 Instance& map = Instance::Handle(); |
| 623 map ^= Api::UnwrapHandle(h_result); |
| 624 const intptr_t kLoopCount = 100; |
| 625 Isolate* isolate = Isolate::Current(); |
| 626 uint8_t* buffer; |
| 627 Timer timer(true, "Large Map"); |
| 628 timer.Start(); |
| 629 for (intptr_t i = 0; i < kLoopCount; i++) { |
| 630 StackZone zone(isolate); |
| 631 MessageWriter writer(&buffer, &malloc_allocator, true); |
| 632 writer.WriteMessage(map); |
| 633 intptr_t buffer_len = writer.BytesWritten(); |
| 634 |
| 635 // Read object back from the snapshot. |
| 636 MessageSnapshotReader reader(buffer, |
| 637 buffer_len, |
| 638 isolate, |
| 639 zone.GetZone()); |
| 640 reader.ReadObject(); |
| 641 free(buffer); |
| 642 } |
| 643 timer.Stop(); |
| 644 int64_t elapsed_time = timer.TotalElapsedTime(); |
| 645 benchmark->set_score(elapsed_time); |
| 646 } |
| 647 |
| 610 } // namespace dart | 648 } // namespace dart |
| OLD | NEW |