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

Unified Diff: runtime/vm/benchmark_test.cc

Issue 159723003: Add SerializeNull and SerializeSmi benchmark for benchmarking serialization of the messages used in… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/benchmark_test.cc
diff --git a/runtime/vm/benchmark_test.cc b/runtime/vm/benchmark_test.cc
index 94d8baf011a7e821c580c5f42308ca2693ff197f..d8d691b3f860cd14007ec777905e24db97118d84 100644
--- a/runtime/vm/benchmark_test.cc
+++ b/runtime/vm/benchmark_test.cc
@@ -502,4 +502,52 @@ BENCHMARK(EnterExitIsolate) {
benchmark->set_score(elapsed_time);
}
+
+BENCHMARK(SerializeNull) {
+ const Object& null_object = Object::Handle();
+ const intptr_t kLoopCount = 1000000;
+ Isolate* isolate = Isolate::Current();
+ uint8_t* buffer;
+ Timer timer(true, "Serialize Null");
+ timer.Start();
+ for (intptr_t i = 0; i < kLoopCount; i++) {
+ MessageWriter writer(&buffer, &malloc_allocator);
+ writer.WriteMessage(null_object);
+ intptr_t buffer_len = writer.BytesWritten();
+
+ // Read object back from the snapshot.
+ SnapshotReader reader(buffer, buffer_len,
+ Snapshot::kMessage, isolate);
+ reader.ReadObject();
+ free(buffer);
+ }
+ timer.Stop();
+ int64_t elapsed_time = timer.TotalElapsedTime();
+ benchmark->set_score(elapsed_time);
+}
+
+
+BENCHMARK(SerializeSmi) {
+ const Integer& smi_object = Integer::Handle(Smi::New(42));
+ const intptr_t kLoopCount = 1000000;
+ Isolate* isolate = Isolate::Current();
+ uint8_t* buffer;
+ Timer timer(true, "Serialize Smi");
+ timer.Start();
+ for (intptr_t i = 0; i < kLoopCount; i++) {
+ 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.
+ writer.WriteMessage(smi_object);
+ intptr_t buffer_len = writer.BytesWritten();
+
+ // Read object back from the snapshot.
+ SnapshotReader reader(buffer, buffer_len,
+ Snapshot::kMessage, isolate);
+ reader.ReadObject();
+ free(buffer);
+ }
+ timer.Stop();
+ int64_t elapsed_time = timer.TotalElapsedTime();
+ benchmark->set_score(elapsed_time);
+}
+
} // namespace dart
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698