Skip to content

Commit ce95a4d

Browse files
caitpCommit bot
authored andcommitted
[es6] add js-perf-test for rest parameters
BUG=v8:2160 LOG=N R=adamk, rossberg, wingo Review URL: https://codereview.chromium.org/1317113007 Cr-Commit-Position: refs/heads/master@{#30647}
1 parent e4a8161 commit ce95a4d

3 files changed

Lines changed: 69 additions & 0 deletions

File tree

test/js-perf-test/JSTests.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,19 @@
88
"total": true,
99
"resources": ["base.js"],
1010
"tests": [
11+
{
12+
"name": "RestParameters",
13+
"path": ["RestParameters"],
14+
"main": "run.js",
15+
"resources": ["rest.js"],
16+
"flags": ["--harmony-rest-parameters"],
17+
"run_count": 5,
18+
"units": "score",
19+
"results_regexp": "^%s\\-RestParameters\\(Score\\): (.+)$",
20+
"tests": [
21+
{"name": "BasicRest1"}
22+
]
23+
},
1124
{
1225
"name": "SpreadCalls",
1326
"path": ["SpreadCalls"],
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright 2015 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+
new BenchmarkSuite('Basic', [1000], [
6+
new Benchmark('BasicRest1', false, false, 0,
7+
BasicRest1, BasicRest1Setup, BasicRest1TearDown)
8+
]);
9+
10+
// ----------------------------------------------------------------------------
11+
12+
var result;
13+
14+
function basic_rest_fn_1(factor, ...values) {
15+
var result = 0;
16+
for (var i = 0; i < values.length; ++i) {
17+
result += (factor * values[i]);
18+
}
19+
return result;
20+
}
21+
22+
function BasicRest1Setup() {}
23+
24+
function BasicRest1() {
25+
result = basic_rest_fn_1(10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
26+
}
27+
28+
function BasicRest1TearDown() {
29+
return result == 550;
30+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright 2015 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+
load('../base.js');
7+
load('rest.js');
8+
9+
var success = true;
10+
11+
function PrintResult(name, result) {
12+
print(name + '-RestParameters(Score): ' + result);
13+
}
14+
15+
16+
function PrintError(name, error) {
17+
PrintResult(name, error);
18+
success = false;
19+
}
20+
21+
22+
BenchmarkSuite.config.doWarmup = undefined;
23+
BenchmarkSuite.config.doDeterministic = undefined;
24+
25+
BenchmarkSuite.RunSuites({ NotifyResult: PrintResult,
26+
NotifyError: PrintError });

0 commit comments

Comments
 (0)