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

Unified Diff: test/perf-test/Collections/set.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/run.js ('k') | test/perf-test/Collections/weakmap.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/perf-test/Collections/set.js
diff --git a/test/perf-test/Collections/set.js b/test/perf-test/Collections/set.js
new file mode 100644
index 0000000000000000000000000000000000000000..e6455e1c0afe15fb8196e1b1862668d7ca111d34
--- /dev/null
+++ b/test/perf-test/Collections/set.js
@@ -0,0 +1,66 @@
+// 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 SetBenchmark = new BenchmarkSuite('Set', [1000], [
+ new Benchmark('Add', false, false, 0, SetAdd),
+ new Benchmark('Has', false, false, 0, SetHas, SetSetup, SetTearDown),
+ new Benchmark('Delete', false, false, 0, SetDelete, SetSetup, SetTearDown),
+ new Benchmark('ForEach', false, false, 0, SetForEach, SetSetup, SetTearDown),
+]);
+
+
+var set;
+var N = 10;
+
+
+function SetSetup() {
+ set = new Set;
+ for (var i = 0; i < N; i++) {
+ set.add(i);
+ }
+}
+
+
+function SetTearDown() {
+ map = null;
+}
+
+
+function SetAdd() {
+ SetSetup();
+ SetTearDown();
+}
+
+
+function SetHas() {
+ for (var i = 0; i < N; i++) {
+ if (!set.has(i)) {
+ throw new Error();
+ }
+ }
+ for (var i = N; i < 2 * N; i++) {
+ if (set.has(i)) {
+ throw new Error();
+ }
+ }
+}
+
+
+function SetDelete() {
+ // 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++) {
+ set.delete(i);
+ }
+}
+
+
+function SetForEach() {
+ set.forEach(function(v, k) {
+ if (v !== k) {
+ throw new Error();
+ }
+ });
+}
« no previous file with comments | « test/perf-test/Collections/run.js ('k') | test/perf-test/Collections/weakmap.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698