Add spread call micro-benchmarks.

Taken from http://kpdecker.github.io/six-speed/

Review-Url: https://codereview.chromium.org/2467483002
Cr-Commit-Position: refs/heads/master@{#40837}
This commit is contained in:
yangguo 2016-11-08 06:16:58 -08:00 committed by Commit bot
parent 083e465f3b
commit 7159662b31
4 changed files with 147 additions and 0 deletions

View File

@ -0,0 +1,27 @@
{
"name": "SixSpeed",
"run_count": 3,
"run_count_arm": 1,
"run_count_arm64": 1,
"timeout": 120,
"units": "score",
"total": true,
"resources": ["base.js"],
"tests": [
{
"name": "Spread",
"path": ["SixSpeed/spread"],
"main": "run.js",
"resources": [
"run.js",
"spread.js"
],
"results_regexp": "^%s\\(Score\\): (.+)$",
"tests": [
{"name": "Spread-ES5"},
{"name": "Spread-Traceur"},
{"name": "Spread-ES6"}
]
}
]
}

View File

@ -0,0 +1,22 @@
Tests included here are based on build output generated by the six-speed
benchmark suite.
Copyright (c) 2015 Kevin Decker
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -0,0 +1,25 @@
// Copyright 2016 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('spread.js');
var success = true;
function PrintResult(name, result) {
print(name + '(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 });

View File

@ -0,0 +1,73 @@
// Copyright 2016 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('Spread-ES5', [1000], [
new Benchmark('ES5', false, false, 0, ES5),
]);
new BenchmarkSuite('Spread-Traceur', [1000], [
new Benchmark('Traceur', false, false, 0, Traceur),
]);
new BenchmarkSuite('Spread-ES6', [1000], [
new Benchmark('ES6', false, false, 0, ES6),
]);
// ----------------------------------------------------------------------------
// Benchmark: ES5
// ----------------------------------------------------------------------------
function ES5() {
"use strict";
return Math.max.apply(Math, [1,2,3]);
}
// ----------------------------------------------------------------------------
// Benchmark: Traceur
// ----------------------------------------------------------------------------
function checkObjectCoercible(v) {
"use strict";
if (v === null || v === undefined) {
throw new $TypeError('Value cannot be converted to an Object');
}
return v;
}
function spread() {
"use strict";
var rv = [],
j = 0,
iterResult;
for (var i = 0; i < arguments.length; i++) {
var valueToSpread = checkObjectCoercible(arguments[i]);
if (typeof valueToSpread[Symbol.iterator] !== 'function') {
throw new TypeError('Cannot spread non-iterable object.');
}
var iter = valueToSpread[Symbol.iterator]();
while (!(iterResult = iter.next()).done) {
rv[j++] = iterResult.value;
}
}
return rv;
}
function Traceur() {
"use strict";
var $__0;
return ($__0 = Math).max.apply($__0, spread([1, 2, 3]));
}
// ----------------------------------------------------------------------------
// Benchmark: ES6
// ----------------------------------------------------------------------------
function ES6() {
"use strict";
return Math.max(...[1,2,3]);
}