[benchmarks] Add ES6 Map/Set benchmarks from SixSpeed

Bug: v8:5717
Change-Id: I92c6d897ae7701e6c778590709f6f1c8a16295b0
Reviewed-on: https://chromium-review.googlesource.com/478591
Reviewed-by: Franziska Hinkelmann <franzih@chromium.org>
Commit-Queue: Sathya Gunasekaran <gsathya@chromium.org>
Cr-Commit-Position: refs/heads/master@{#44696}
This commit is contained in:
Sathya Gunasekaran 2017-04-14 14:48:05 -07:00 committed by Commit Bot
parent 1979ab55fb
commit 2e4b86b0de
9 changed files with 279 additions and 0 deletions

View File

@ -142,6 +142,82 @@
"test_flags": ["spread_literal/es6"]
}
]
},
{
"name": "Map-Set has",
"path": ["SixSpeed"],
"results_regexp": "^%s\\(Score\\): (.+)$",
"tests": [
{
"name": "ES5",
"main": "run.js",
"resources": ["map_set_lookup/es5.js"],
"test_flags": ["map_set_lookup/es5"]
},
{
"name": "ES6",
"main": "run.js",
"resources": ["map_set_lookup/es6.js"],
"test_flags": ["map_set_lookup/es6"]
}
]
},
{
"name": "Map-Set add-set-has",
"path": ["SixSpeed"],
"results_regexp": "^%s\\(Score\\): (.+)$",
"tests": [
{
"name": "ES5",
"main": "run.js",
"resources": ["map_set_add/es5.js"],
"test_flags": ["map_set_add/es5"]
},
{
"name": "ES6",
"main": "run.js",
"resources": ["map_set_add/es6.js"],
"test_flags": ["map_set_add/es6"]
}
]
},
{
"name": "Map-Set add-set-has object",
"path": ["SixSpeed"],
"results_regexp": "^%s\\(Score\\): (.+)$",
"tests": [
{
"name": "ES5",
"main": "run.js",
"resources": ["map_set_object/es5.js"],
"test_flags": ["map_set_object/es5"]
},
{
"name": "ES6",
"main": "run.js",
"resources": ["map_set_object/es6.js"],
"test_flags": ["map_set_object/es6"]
}
]
},
{
"name": "Map get string",
"path": ["SixSpeed"],
"results_regexp": "^%s\\(Score\\): (.+)$",
"tests": [
{
"name": "ES5",
"main": "run.js",
"resources": ["map_set_add/es5.js"],
"test_flags": ["map_set_add/es5"]
},
{
"name": "ES6",
"main": "run.js",
"resources": ["map_set_add/es6.js"],
"test_flags": ["map_set_add/es6"]
}
]
}
]
}

View File

@ -0,0 +1,21 @@
// Copyright 2017 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.
// This benchmark is based on the six-speed benchmark build output.
// Copyright 2014 Kevin Decker <https://github.com/kpdecker/six-speed/>
new BenchmarkSuite("ES5", [1000], [new Benchmark("ES5", false, false, 0, ES5)]);
function ES5() {
var map = {}, set = [];
for (var i = 0; i < 250; i++) {
map[i] = i;
set.push(i);
}
map.foo = "bar";
set.push("bar");
return "foo" in map && set.indexOf("bar") >= 0;
}

View File

@ -0,0 +1,22 @@
// Copyright 2017 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.
// This benchmark is based on the six-speed benchmark build output.
// Copyright 2014 Kevin Decker <https://github.com/kpdecker/six-speed/>
new BenchmarkSuite("ES6", [1000], [new Benchmark("ES6", false, false, 0, ES6)]);
function ES6() {
var map = new Map(), set = new Set();
for (var i = 0; i < 250; i++) {
map.set(i, i);
set.add(i);
}
map.set("foo", "bar");
set.add("bar");
return map.has("foo") && set.has("bar");
}

View File

@ -0,0 +1,32 @@
// Copyright 2017 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.
// This benchmark is based on the six-speed benchmark build output.
// Copyright 2014 Kevin Decker <https://github.com/kpdecker/six-speed/>
new BenchmarkSuite(
"ES5",
[1000],
[new Benchmark("ES5", false, false, 0, ES5, Setup)]
);
var keys, values, set, key;
function Setup() {
(keys = []), (values = []), (set = []), (key = {});
for (var i = 0; i < 500; i++) {
keys.push(i);
values.push(i);
set.push(i);
}
keys.push(key);
values.push("bar");
set.push(key);
}
function ES5() {
return set.indexOf(key) >= 0 && keys.indexOf(key) >= 0;
}

View File

@ -0,0 +1,30 @@
// Copyright 2017 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.
// This benchmark is based on the six-speed benchmark build output.
// Copyright 2014 Kevin Decker <https://github.com/kpdecker/six-speed/>
new BenchmarkSuite(
"ES6",
[1000],
[new Benchmark("ES6", false, false, 0, ES6, Setup)]
);
var map, set, key;
function Setup() {
(map = new Map()), (set = new Set()), (key = {});
for (var i = 0; i < 500; i++) {
map.set(i, i);
set.add(i);
}
map.set(key, "bar");
set.add(key);
}
function ES6() {
return map.has(key) && set.has(key);
}

View File

@ -0,0 +1,24 @@
// Copyright 2017 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.
// This benchmark is based on the six-speed benchmark build output.
// Copyright 2014 Kevin Decker <https://github.com/kpdecker/six-speed/>
new BenchmarkSuite("ES5", [1000], [new Benchmark("ES5", false, false, 0, ES5)]);
function ES5() {
var keys = [], values = [], set = [], key = {};
for (var i = 0; i < 500; i++) {
keys.push(i);
values.push(i);
set.push(i);
}
keys.push(key);
values.push("bar");
set.push(key);
return set.indexOf(key) >= 0 && keys.indexOf(key) >= 0;
}

View File

@ -0,0 +1,22 @@
// Copyright 2017 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.
// This benchmark is based on the six-speed benchmark build output.
// Copyright 2014 Kevin Decker <https://github.com/kpdecker/six-speed/>
new BenchmarkSuite("ES6", [1000], [new Benchmark("ES6", false, false, 0, ES6)]);
function ES6() {
var map = new Map(), set = new Set(), key = {};
for (var i = 0; i < 500; i++) {
map.set(i, i);
set.add(i);
}
map.set(key, "bar");
set.add(key);
return map.has(key) && set.has(key);
}

View File

@ -0,0 +1,26 @@
// Copyright 2017 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.
// This benchmark is based on the six-speed benchmark build output.
// Copyright 2014 Kevin Decker <https://github.com/kpdecker/six-speed/>
new BenchmarkSuite(
"ES5",
[1000],
[new Benchmark("ES5", false, false, 0, ES5, Setup)]
);
var map;
function Setup() {
map = {};
for (var i = 0; i < 500; i++) {
map[i] = i;
}
}
function ES5() {
return map["499"] === 499;
}

View File

@ -0,0 +1,26 @@
// Copyright 2017 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.
// This benchmark is based on the six-speed benchmark build output.
// Copyright 2014 Kevin Decker <https://github.com/kpdecker/six-speed/>
new BenchmarkSuite(
"ES6",
[1000],
[new Benchmark("ES6", false, false, 0, ES6, Setup)]
);
var map;
function Setup() {
map = new Map();
for (var i = 0; i < 500; i++) {
map.set(i + "", i);
}
}
function ES6() {
return map.get("499") === 499;
}