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 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 | 522 |
523 BENCHMARK(SerializeNull) { | 523 BENCHMARK(SerializeNull) { |
524 const Object& null_object = Object::Handle(); | 524 const Object& null_object = Object::Handle(); |
525 const intptr_t kLoopCount = 1000000; | 525 const intptr_t kLoopCount = 1000000; |
526 Isolate* isolate = Isolate::Current(); | 526 Isolate* isolate = Isolate::Current(); |
527 uint8_t* buffer; | 527 uint8_t* buffer; |
528 Timer timer(true, "Serialize Null"); | 528 Timer timer(true, "Serialize Null"); |
529 timer.Start(); | 529 timer.Start(); |
530 for (intptr_t i = 0; i < kLoopCount; i++) { | 530 for (intptr_t i = 0; i < kLoopCount; i++) { |
531 StackZone zone(isolate); | 531 StackZone zone(isolate); |
532 MessageWriter writer(&buffer, &message_allocator); | 532 MessageWriter writer(&buffer, &message_allocator, true); |
533 writer.WriteMessage(null_object); | 533 writer.WriteMessage(null_object); |
534 intptr_t buffer_len = writer.BytesWritten(); | 534 intptr_t buffer_len = writer.BytesWritten(); |
535 | 535 |
536 // Read object back from the snapshot. | 536 // Read object back from the snapshot. |
537 SnapshotReader reader(buffer, buffer_len, Snapshot::kMessage, isolate); | 537 SnapshotReader reader(buffer, buffer_len, Snapshot::kMessage, isolate); |
538 reader.ReadObject(); | 538 reader.ReadObject(); |
539 } | 539 } |
540 timer.Stop(); | 540 timer.Stop(); |
541 int64_t elapsed_time = timer.TotalElapsedTime(); | 541 int64_t elapsed_time = timer.TotalElapsedTime(); |
542 benchmark->set_score(elapsed_time); | 542 benchmark->set_score(elapsed_time); |
543 } | 543 } |
544 | 544 |
545 | 545 |
546 BENCHMARK(SerializeSmi) { | 546 BENCHMARK(SerializeSmi) { |
547 const Integer& smi_object = Integer::Handle(Smi::New(42)); | 547 const Integer& smi_object = Integer::Handle(Smi::New(42)); |
548 const intptr_t kLoopCount = 1000000; | 548 const intptr_t kLoopCount = 1000000; |
549 Isolate* isolate = Isolate::Current(); | 549 Isolate* isolate = Isolate::Current(); |
550 uint8_t* buffer; | 550 uint8_t* buffer; |
551 Timer timer(true, "Serialize Smi"); | 551 Timer timer(true, "Serialize Smi"); |
552 timer.Start(); | 552 timer.Start(); |
553 for (intptr_t i = 0; i < kLoopCount; i++) { | 553 for (intptr_t i = 0; i < kLoopCount; i++) { |
554 StackZone zone(isolate); | 554 StackZone zone(isolate); |
555 MessageWriter writer(&buffer, &message_allocator); | 555 MessageWriter writer(&buffer, &message_allocator, true); |
556 writer.WriteMessage(smi_object); | 556 writer.WriteMessage(smi_object); |
557 intptr_t buffer_len = writer.BytesWritten(); | 557 intptr_t buffer_len = writer.BytesWritten(); |
558 | 558 |
559 // Read object back from the snapshot. | 559 // Read object back from the snapshot. |
560 SnapshotReader reader(buffer, buffer_len, Snapshot::kMessage, isolate); | 560 SnapshotReader reader(buffer, buffer_len, Snapshot::kMessage, isolate); |
561 reader.ReadObject(); | 561 reader.ReadObject(); |
562 } | 562 } |
563 timer.Stop(); | 563 timer.Stop(); |
564 int64_t elapsed_time = timer.TotalElapsedTime(); | 564 int64_t elapsed_time = timer.TotalElapsedTime(); |
565 benchmark->set_score(elapsed_time); | 565 benchmark->set_score(elapsed_time); |
566 } | 566 } |
567 | 567 |
568 | 568 |
569 BENCHMARK(SimpleMessage) { | 569 BENCHMARK(SimpleMessage) { |
570 const Array& array_object = Array::Handle(Array::New(2)); | 570 const Array& array_object = Array::Handle(Array::New(2)); |
571 array_object.SetAt(0, Integer::Handle(Smi::New(42))); | 571 array_object.SetAt(0, Integer::Handle(Smi::New(42))); |
572 array_object.SetAt(1, Object::Handle()); | 572 array_object.SetAt(1, Object::Handle()); |
573 const intptr_t kLoopCount = 1000000; | 573 const intptr_t kLoopCount = 1000000; |
574 Isolate* isolate = Isolate::Current(); | 574 Isolate* isolate = Isolate::Current(); |
575 uint8_t* buffer; | 575 uint8_t* buffer; |
576 Timer timer(true, "Simple Message"); | 576 Timer timer(true, "Simple Message"); |
577 timer.Start(); | 577 timer.Start(); |
578 for (intptr_t i = 0; i < kLoopCount; i++) { | 578 for (intptr_t i = 0; i < kLoopCount; i++) { |
579 StackZone zone(isolate); | 579 StackZone zone(isolate); |
580 MessageWriter writer(&buffer, &malloc_allocator); | 580 MessageWriter writer(&buffer, &malloc_allocator, true); |
581 writer.WriteMessage(array_object); | 581 writer.WriteMessage(array_object); |
582 intptr_t buffer_len = writer.BytesWritten(); | 582 intptr_t buffer_len = writer.BytesWritten(); |
583 | 583 |
584 // Read object back from the snapshot. | 584 // Read object back from the snapshot. |
585 SnapshotReader reader(buffer, buffer_len, Snapshot::kMessage, isolate); | 585 SnapshotReader reader(buffer, buffer_len, Snapshot::kMessage, isolate); |
586 reader.ReadObject(); | 586 reader.ReadObject(); |
587 free(buffer); | 587 free(buffer); |
588 } | 588 } |
589 timer.Stop(); | 589 timer.Stop(); |
590 int64_t elapsed_time = timer.TotalElapsedTime(); | 590 int64_t elapsed_time = timer.TotalElapsedTime(); |
591 benchmark->set_score(elapsed_time); | 591 benchmark->set_score(elapsed_time); |
592 } | 592 } |
593 | 593 |
594 } // namespace dart | 594 } // namespace dart |
OLD | NEW |