Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(126)

Side by Side Diff: runtime/vm/benchmark_test.cc

Issue 528073002: Don't leak memory between iterations of the message serialization benchmarks. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/tests/vm/vm.status ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 504
505 505
506 BENCHMARK(SerializeNull) { 506 BENCHMARK(SerializeNull) {
507 const Object& null_object = Object::Handle(); 507 const Object& null_object = Object::Handle();
508 const intptr_t kLoopCount = 1000000; 508 const intptr_t kLoopCount = 1000000;
509 Isolate* isolate = Isolate::Current(); 509 Isolate* isolate = Isolate::Current();
510 uint8_t* buffer; 510 uint8_t* buffer;
511 Timer timer(true, "Serialize Null"); 511 Timer timer(true, "Serialize Null");
512 timer.Start(); 512 timer.Start();
513 for (intptr_t i = 0; i < kLoopCount; i++) { 513 for (intptr_t i = 0; i < kLoopCount; i++) {
514 StackZone zone(isolate);
514 MessageWriter writer(&buffer, &message_allocator); 515 MessageWriter writer(&buffer, &message_allocator);
515 writer.WriteMessage(null_object); 516 writer.WriteMessage(null_object);
516 intptr_t buffer_len = writer.BytesWritten(); 517 intptr_t buffer_len = writer.BytesWritten();
517 518
518 // Read object back from the snapshot. 519 // Read object back from the snapshot.
519 SnapshotReader reader(buffer, buffer_len, Snapshot::kMessage, isolate); 520 SnapshotReader reader(buffer, buffer_len, Snapshot::kMessage, isolate);
520 reader.ReadObject(); 521 reader.ReadObject();
521 } 522 }
522 timer.Stop(); 523 timer.Stop();
523 int64_t elapsed_time = timer.TotalElapsedTime(); 524 int64_t elapsed_time = timer.TotalElapsedTime();
524 benchmark->set_score(elapsed_time); 525 benchmark->set_score(elapsed_time);
525 } 526 }
526 527
527 528
528 BENCHMARK(SerializeSmi) { 529 BENCHMARK(SerializeSmi) {
529 const Integer& smi_object = Integer::Handle(Smi::New(42)); 530 const Integer& smi_object = Integer::Handle(Smi::New(42));
530 const intptr_t kLoopCount = 1000000; 531 const intptr_t kLoopCount = 1000000;
531 Isolate* isolate = Isolate::Current(); 532 Isolate* isolate = Isolate::Current();
532 uint8_t* buffer; 533 uint8_t* buffer;
533 Timer timer(true, "Serialize Smi"); 534 Timer timer(true, "Serialize Smi");
534 timer.Start(); 535 timer.Start();
535 for (intptr_t i = 0; i < kLoopCount; i++) { 536 for (intptr_t i = 0; i < kLoopCount; i++) {
537 StackZone zone(isolate);
536 MessageWriter writer(&buffer, &message_allocator); 538 MessageWriter writer(&buffer, &message_allocator);
537 writer.WriteMessage(smi_object); 539 writer.WriteMessage(smi_object);
538 intptr_t buffer_len = writer.BytesWritten(); 540 intptr_t buffer_len = writer.BytesWritten();
539 541
540 // Read object back from the snapshot. 542 // Read object back from the snapshot.
541 SnapshotReader reader(buffer, buffer_len, Snapshot::kMessage, isolate); 543 SnapshotReader reader(buffer, buffer_len, Snapshot::kMessage, isolate);
542 reader.ReadObject(); 544 reader.ReadObject();
543 } 545 }
544 timer.Stop(); 546 timer.Stop();
545 int64_t elapsed_time = timer.TotalElapsedTime(); 547 int64_t elapsed_time = timer.TotalElapsedTime();
546 benchmark->set_score(elapsed_time); 548 benchmark->set_score(elapsed_time);
547 } 549 }
548 550
549 551
550 BENCHMARK(SimpleMessage) { 552 BENCHMARK(SimpleMessage) {
551 const Array& array_object = Array::Handle(Array::New(2)); 553 const Array& array_object = Array::Handle(Array::New(2));
552 array_object.SetAt(0, Integer::Handle(Smi::New(42))); 554 array_object.SetAt(0, Integer::Handle(Smi::New(42)));
553 array_object.SetAt(1, Object::Handle()); 555 array_object.SetAt(1, Object::Handle());
554 const intptr_t kLoopCount = 1000000; 556 const intptr_t kLoopCount = 1000000;
555 Isolate* isolate = Isolate::Current(); 557 Isolate* isolate = Isolate::Current();
556 uint8_t* buffer; 558 uint8_t* buffer;
557 Timer timer(true, "Simple Message"); 559 Timer timer(true, "Simple Message");
558 timer.Start(); 560 timer.Start();
559 for (intptr_t i = 0; i < kLoopCount; i++) { 561 for (intptr_t i = 0; i < kLoopCount; i++) {
562 StackZone zone(isolate);
560 MessageWriter writer(&buffer, &malloc_allocator); 563 MessageWriter writer(&buffer, &malloc_allocator);
561 writer.WriteMessage(array_object); 564 writer.WriteMessage(array_object);
562 intptr_t buffer_len = writer.BytesWritten(); 565 intptr_t buffer_len = writer.BytesWritten();
563 566
564 // Read object back from the snapshot. 567 // Read object back from the snapshot.
565 SnapshotReader reader(buffer, buffer_len, Snapshot::kMessage, isolate); 568 SnapshotReader reader(buffer, buffer_len, Snapshot::kMessage, isolate);
566 reader.ReadObject(); 569 reader.ReadObject();
567 free(buffer); 570 free(buffer);
568 } 571 }
569 timer.Stop(); 572 timer.Stop();
570 int64_t elapsed_time = timer.TotalElapsedTime(); 573 int64_t elapsed_time = timer.TotalElapsedTime();
571 benchmark->set_score(elapsed_time); 574 benchmark->set_score(elapsed_time);
572 } 575 }
573 576
574 } // namespace dart 577 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/tests/vm/vm.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698