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

Side by Side 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, 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/base.js ('k') | test/perf-test/Collections/run.js » ('j') | 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 MapBenchmark = new BenchmarkSuite('Map', [1000], [
7 new Benchmark('Set', false, false, 0, MapSet),
8 new Benchmark('Has', false, false, 0, MapHas, MapSetup, MapTearDown),
9 new Benchmark('Get', false, false, 0, MapGet, MapSetup, MapTearDown),
10 new Benchmark('Delete', false, false, 0, MapDelete, MapSetup, MapTearDown),
11 new Benchmark('ForEach', false, false, 0, MapForEach, MapSetup, MapTearDown),
12 ]);
13
14
15 var map;
16 var N = 10;
17
18
19 function MapSetup() {
20 map = new Map;
21 for (var i = 0; i < N; i++) {
22 map.set(i, i);
23 }
24 }
25
26
27 function MapTearDown() {
28 map = null;
29 }
30
31
32 function MapSet() {
33 MapSetup();
34 MapTearDown();
35 }
36
37
38 function MapHas() {
39 for (var i = 0; i < N; i++) {
40 if (!map.has(i)) {
41 throw new Error();
42 }
43 }
44 for (var i = N; i < 2 * N; i++) {
45 if (map.has(i)) {
46 throw new Error();
47 }
48 }
49 }
50
51
52 function MapGet() {
53 for (var i = 0; i < N; i++) {
54 if (map.get(i) !== i) {
55 throw new Error();
56 }
57 }
58 for (var i = N; i < 2 * N; i++) {
59 if (map.get(i) !== undefined) {
60 throw new Error();
61 }
62 }
63 }
64
65
66 function MapDelete() {
67 // This is run more than once per setup so we will end up deleting items
68 // more than once. Therefore, we do not the return value of delete.
69 for (var i = 0; i < N; i++) {
70 map.delete(i);
71 }
72 }
73
74
75 function MapForEach() {
76 map.forEach(function(v, k) {
77 if (v !== k) {
78 throw new Error();
79 }
80 });
81 }
OLDNEW
« 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