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.
6 var SetBenchmark = new BenchmarkSuite('WeakSet', [1000], [
7 new Benchmark('Add', false, false, 0, WeakSetAdd, WeakSetSetupBase,
9 new Benchmark('Has', false, false, 0, WeakSetHas, WeakSetSetup,
11 new Benchmark('Delete', false, false, 0, WeakSetDelete, WeakSetSetup,
19 function WeakSetSetupBase() {
25 function WeakSetSetup() {
31 function WeakSetTearDown() {
36 function WeakSetAdd() {
37 for (var i = 0; i < N; i++) {
43 function WeakSetHas() {
44 for (var i = 0; i < N; i++) {
45 if (!ws.has(keys[i])) {
49 for (var i = N; i < 2 * N; i++) {
50 if (ws.has(keys[i])) {
57 function WeakSetDelete() {
58 // This is run more than once per setup so we will end up deleting items
59 // more than once. Therefore, we do not the return value of delete.
60 for (var i = 0; i < N; i++) {