Chromium Code Reviews| 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 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 495 timer.Start(); | 495 timer.Start(); |
| 496 for (intptr_t i = 0; i < kLoopCount; i++) { | 496 for (intptr_t i = 0; i < kLoopCount; i++) { |
| 497 Dart_ExitIsolate(); | 497 Dart_ExitIsolate(); |
| 498 Dart_EnterIsolate(isolate); | 498 Dart_EnterIsolate(isolate); |
| 499 } | 499 } |
| 500 timer.Stop(); | 500 timer.Stop(); |
| 501 int64_t elapsed_time = timer.TotalElapsedTime(); | 501 int64_t elapsed_time = timer.TotalElapsedTime(); |
| 502 benchmark->set_score(elapsed_time); | 502 benchmark->set_score(elapsed_time); |
| 503 } | 503 } |
| 504 | 504 |
| 505 | |
| 506 BENCHMARK(SerializeNull) { | |
| 507 const Object& null_object = Object::Handle(); | |
| 508 const intptr_t kLoopCount = 1000000; | |
| 509 Isolate* isolate = Isolate::Current(); | |
| 510 uint8_t* buffer; | |
| 511 Timer timer(true, "Serialize Null"); | |
| 512 timer.Start(); | |
| 513 for (intptr_t i = 0; i < kLoopCount; i++) { | |
| 514 MessageWriter writer(&buffer, &malloc_allocator); | |
| 515 writer.WriteMessage(null_object); | |
| 516 intptr_t buffer_len = writer.BytesWritten(); | |
| 517 | |
| 518 // Read object back from the snapshot. | |
| 519 SnapshotReader reader(buffer, buffer_len, | |
| 520 Snapshot::kMessage, isolate); | |
| 521 reader.ReadObject(); | |
| 522 free(buffer); | |
| 523 } | |
| 524 timer.Stop(); | |
| 525 int64_t elapsed_time = timer.TotalElapsedTime(); | |
| 526 benchmark->set_score(elapsed_time); | |
| 527 } | |
| 528 | |
| 529 | |
| 530 BENCHMARK(SerializeSmi) { | |
| 531 const Integer& smi_object = Integer::Handle(Smi::New(42)); | |
| 532 const intptr_t kLoopCount = 1000000; | |
| 533 Isolate* isolate = Isolate::Current(); | |
| 534 uint8_t* buffer; | |
| 535 Timer timer(true, "Serialize Smi"); | |
| 536 timer.Start(); | |
| 537 for (intptr_t i = 0; i < kLoopCount; i++) { | |
| 538 MessageWriter writer(&buffer, &malloc_allocator); | |
|
siva
2014/02/11 23:50:41
sing malloc_allocator here means that you are meas
Anders Johnsen
2014/02/12 07:23:26
This was actually on purpose. I'm trying to unders
siva
2014/02/12 19:29:23
I agree that you want to measure what goes on in t
Anders Johnsen
2014/03/18 19:26:48
Done.
| |
| 539 writer.WriteMessage(smi_object); | |
| 540 intptr_t buffer_len = writer.BytesWritten(); | |
| 541 | |
| 542 // Read object back from the snapshot. | |
| 543 SnapshotReader reader(buffer, buffer_len, | |
| 544 Snapshot::kMessage, isolate); | |
| 545 reader.ReadObject(); | |
| 546 free(buffer); | |
| 547 } | |
| 548 timer.Stop(); | |
| 549 int64_t elapsed_time = timer.TotalElapsedTime(); | |
| 550 benchmark->set_score(elapsed_time); | |
| 551 } | |
| 552 | |
| 505 } // namespace dart | 553 } // namespace dart |
| OLD | NEW |