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

Unified Diff: runtime/vm/benchmark_test.cc

Issue 1151523002: VM-internalize the default Map implementation. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Fix fingerprints. Created 5 years, 7 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 | « runtime/lib/linked_hash_map.dart ('k') | runtime/vm/bootstrap_natives.h » ('j') | 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 51259a58a6e76cfc3544a68c81108858fadad713..a6d6c18286211626e747c8248d6faa920c2f7250 100644
--- a/runtime/vm/benchmark_test.cc
+++ b/runtime/vm/benchmark_test.cc
@@ -607,4 +607,42 @@ BENCHMARK(SimpleMessage) {
benchmark->set_score(elapsed_time);
}
+
+BENCHMARK(LargeMap) {
+ const char* kScript =
+ "makeMap() {\n"
+ " Map m = {};\n"
+ " for (int i = 0; i < 100000; ++i) m[i*13+i*(i>>7)] = i;\n"
+ " return m;\n"
+ "}";
+ Dart_Handle h_lib = TestCase::LoadTestScript(kScript, NULL);
+ EXPECT_VALID(h_lib);
+ Dart_Handle h_result = Dart_Invoke(h_lib, NewString("makeMap"), 0, NULL);
+ EXPECT_VALID(h_result);
+ Instance& map = Instance::Handle();
+ map ^= Api::UnwrapHandle(h_result);
+ const intptr_t kLoopCount = 100;
+ Isolate* isolate = Isolate::Current();
+ uint8_t* buffer;
+ Timer timer(true, "Large Map");
+ timer.Start();
+ for (intptr_t i = 0; i < kLoopCount; i++) {
+ StackZone zone(isolate);
+ MessageWriter writer(&buffer, &malloc_allocator, true);
+ writer.WriteMessage(map);
+ intptr_t buffer_len = writer.BytesWritten();
+
+ // Read object back from the snapshot.
+ MessageSnapshotReader reader(buffer,
+ buffer_len,
+ isolate,
+ zone.GetZone());
+ reader.ReadObject();
+ free(buffer);
+ }
+ timer.Stop();
+ int64_t elapsed_time = timer.TotalElapsedTime();
+ benchmark->set_score(elapsed_time);
+}
+
} // namespace dart
« no previous file with comments | « runtime/lib/linked_hash_map.dart ('k') | runtime/vm/bootstrap_natives.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698