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

Side by Side Diff: test/perf-test/Collections/weakset.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, 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 | « test/perf-test/Collections/weakmap.js ('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
(Empty)
1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5
6 var SetBenchmark = new BenchmarkSuite('WeakSet', [1000], [
7 new Benchmark('Add', false, false, 0, WeakSetAdd),
8 new Benchmark('Has', false, false, 0, WeakSetHas, WeakSetSetup,
9 WeakSetTearDown),
10 new Benchmark('Delete', false, false, 0, WeakSetDelete, WeakSetSetup,
11 WeakSetTearDown),
12 ]);
13
14
15 var ws;
16 var N = 10;
17 var keys = [];
18
19
20 for (var i = 0; i < N * 2; i++) {
21 keys[i] = {};
22 }
23
24
25 function WeakSetSetup() {
26 ws = new WeakSet;
27 for (var i = 0; i < N; i++) {
28 ws.add(keys[i]);
29 }
30 }
31
32
33 function WeakSetTearDown() {
34 ws = null;
35 }
36
37
38 function WeakSetAdd() {
39 WeakSetSetup();
40 WeakSetTearDown();
41 }
42
43
44 function WeakSetHas() {
45 for (var i = 0; i < N; i++) {
46 if (!ws.has(keys[i])) {
47 throw new Error();
48 }
49 }
50 for (var i = N; i < 2 * N; i++) {
51 if (ws.has(keys[i])) {
52 throw new Error();
53 }
54 }
55 }
56
57
58 function WeakSetDelete() {
59 // This is run more than once per setup so we will end up deleting items
60 // more than once. Therefore, we do not the return value of delete.
61 for (var i = 0; i < N; i++) {
62 ws.delete(keys[i]);
63 }
64 }
OLDNEW
« no previous file with comments | « test/perf-test/Collections/weakmap.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698