Commit 925298ad authored by dslomov@chromium.org's avatar dslomov@chromium.org

Add Collections perf tests to v8 public repo.

R=machenbach@chromium.org
BUG=374708
LOG=N

Review URL: https://codereview.chromium.org/530793002

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23570 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 68ec0824
{
"path": ["."],
"main": "run.js",
"flags": ["--harmony-collections"],
"run_count": 5,
"units": "score",
"results_regexp": "^%s\\-Collections\\(Score\\): (.+)$",
"total": true,
"tests": [
{"name": "Map"},
{"name": "Set"},
{"name": "WeakMap"},
{"name": "WeakSet"}
]
}
This diff is collapsed.
// 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 MapBenchmark = new BenchmarkSuite('Map', [1000], [
new Benchmark('Set', false, false, 0, MapSet),
new Benchmark('Has', false, false, 0, MapHas, MapSetup, MapTearDown),
new Benchmark('Get', false, false, 0, MapGet, MapSetup, MapTearDown),
new Benchmark('Delete', false, false, 0, MapDelete, MapSetup, MapTearDown),
new Benchmark('ForEach', false, false, 0, MapForEach, MapSetup, MapTearDown),
]);
var map;
var N = 10;
function MapSetup() {
map = new Map;
for (var i = 0; i < N; i++) {
map.set(i, i);
}
}
function MapTearDown() {
map = null;
}
function MapSet() {
MapSetup();
MapTearDown();
}
function MapHas() {
for (var i = 0; i < N; i++) {
if (!map.has(i)) {
throw new Error();
}
}
for (var i = N; i < 2 * N; i++) {
if (map.has(i)) {
throw new Error();
}
}
}
function MapGet() {
for (var i = 0; i < N; i++) {
if (map.get(i) !== i) {
throw new Error();
}
}
for (var i = N; i < 2 * N; i++) {
if (map.get(i) !== undefined) {
throw new Error();
}
}
}
function MapDelete() {
// 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++) {
map.delete(i);
}
}
function MapForEach() {
map.forEach(function(v, k) {
if (v !== k) {
throw new Error();
}
});
}
// 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.
load('base.js');
load('map.js');
load('set.js');
load('weakmap.js');
load('weakset.js');
var success = true;
function PrintResult(name, result) {
print(name + '-Collections(Score): ' + result);
}
function PrintError(name, error) {
PrintResult(name, error);
success = false;
}
BenchmarkSuite.config.doWarmup = undefined;
BenchmarkSuite.config.doDeterministic = undefined;
BenchmarkSuite.RunSuites({ NotifyResult: PrintResult,
NotifyError: PrintError });
// 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();
}
});
}
// 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 MapBenchmark = new BenchmarkSuite('WeakMap', [1000], [
new Benchmark('Set', false, false, 0, WeakMapSet),
new Benchmark('Has', false, false, 0, WeakMapHas, WeakMapSetup,
WeakMapTearDown),
new Benchmark('Get', false, false, 0, WeakMapGet, WeakMapSetup,
WeakMapTearDown),
new Benchmark('Delete', false, false, 0, WeakMapDelete, WeakMapSetup,
WeakMapTearDown),
]);
var wm;
var N = 10;
var keys = [];
for (var i = 0; i < N * 2; i++) {
keys[i] = {};
}
function WeakMapSetup() {
wm = new WeakMap;
for (var i = 0; i < N; i++) {
wm.set(keys[i], i);
}
}
function WeakMapTearDown() {
wm = null;
}
function WeakMapSet() {
WeakMapSetup();
WeakMapTearDown();
}
function WeakMapHas() {
for (var i = 0; i < N; i++) {
if (!wm.has(keys[i])) {
throw new Error();
}
}
for (var i = N; i < 2 * N; i++) {
if (wm.has(keys[i])) {
throw new Error();
}
}
}
function WeakMapGet() {
for (var i = 0; i < N; i++) {
if (wm.get(keys[i]) !== i) {
throw new Error();
}
}
for (var i = N; i < 2 * N; i++) {
if (wm.get(keys[i]) !== undefined) {
throw new Error();
}
}
}
function WeakMapDelete() {
// 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++) {
wm.delete(keys[i]);
}
}
// 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('WeakSet', [1000], [
new Benchmark('Add', false, false, 0, WeakSetAdd),
new Benchmark('Has', false, false, 0, WeakSetHas, WeakSetSetup,
WeakSetTearDown),
new Benchmark('Delete', false, false, 0, WeakSetDelete, WeakSetSetup,
WeakSetTearDown),
]);
var ws;
var N = 10;
var keys = [];
for (var i = 0; i < N * 2; i++) {
keys[i] = {};
}
function WeakSetSetup() {
ws = new WeakSet;
for (var i = 0; i < N; i++) {
ws.add(keys[i]);
}
}
function WeakSetTearDown() {
ws = null;
}
function WeakSetAdd() {
WeakSetSetup();
WeakSetTearDown();
}
function WeakSetHas() {
for (var i = 0; i < N; i++) {
if (!ws.has(keys[i])) {
throw new Error();
}
}
for (var i = N; i < 2 * N; i++) {
if (ws.has(keys[i])) {
throw new Error();
}
}
}
function WeakSetDelete() {
// 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++) {
ws.delete(keys[i]);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment