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

Unified Diff: test/perf-test/Collections/map.js

Issue 530793002: Add Collections perf tests to v8 public repo. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Patch for landing Created 6 years, 4 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 | « test/perf-test/Collections/base.js ('k') | test/perf-test/Collections/run.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/perf-test/Collections/map.js
diff --git a/test/perf-test/Collections/map.js b/test/perf-test/Collections/map.js
new file mode 100644
index 0000000000000000000000000000000000000000..b310a719025ee98c201148f51100a177b8a5ca17
--- /dev/null
+++ b/test/perf-test/Collections/map.js
@@ -0,0 +1,81 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+
+var MapBenchmark = new BenchmarkSuite('Map', [1000], [
+ new Benchmark('Set', false, false, 0, MapSet),
+ new Benchmark('Has', false, false, 0, MapHas, MapSetup, MapTearDown),
+ new Benchmark('Get', false, false, 0, MapGet, MapSetup, MapTearDown),
+ new Benchmark('Delete', false, false, 0, MapDelete, MapSetup, MapTearDown),
+ new Benchmark('ForEach', false, false, 0, MapForEach, MapSetup, MapTearDown),
+]);
+
+
+var map;
+var N = 10;
+
+
+function MapSetup() {
+ map = new Map;
+ for (var i = 0; i < N; i++) {
+ map.set(i, i);
+ }
+}
+
+
+function MapTearDown() {
+ map = null;
+}
+
+
+function MapSet() {
+ MapSetup();
+ MapTearDown();
+}
+
+
+function MapHas() {
+ for (var i = 0; i < N; i++) {
+ if (!map.has(i)) {
+ throw new Error();
+ }
+ }
+ for (var i = N; i < 2 * N; i++) {
+ if (map.has(i)) {
+ throw new Error();
+ }
+ }
+}
+
+
+function MapGet() {
+ for (var i = 0; i < N; i++) {
+ if (map.get(i) !== i) {
+ throw new Error();
+ }
+ }
+ for (var i = N; i < 2 * N; i++) {
+ if (map.get(i) !== undefined) {
+ throw new Error();
+ }
+ }
+}
+
+
+function MapDelete() {
+ // This is run more than once per setup so we will end up deleting items
+ // more than once. Therefore, we do not the return value of delete.
+ for (var i = 0; i < N; i++) {
+ map.delete(i);
+ }
+}
+
+
+function MapForEach() {
+ map.forEach(function(v, k) {
+ if (v !== k) {
+ throw new Error();
+ }
+ });
+}
« no previous file with comments | « test/perf-test/Collections/base.js ('k') | test/perf-test/Collections/run.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698