Perf tests for harmony string functions.

R=yangguo@chromium.org

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24765 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
dslomov@chromium.org 2014-10-21 11:05:32 +00:00
parent 423201ea06
commit ac8b70cf2b
3 changed files with 105 additions and 0 deletions

View File

@ -0,0 +1,12 @@
{
"path": ["."],
"main": "run.js",
"flags": ["--harmony-strings"],
"run_count": 5,
"units": "score",
"results_regexp": "^%s\\-Strings\\(Score\\): (.+)$",
"total": true,
"tests": [
{"name": "StringFunctions"}
]
}

View File

@ -0,0 +1,66 @@
// 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.
new BenchmarkSuite('StringFunctions', [1000], [
new Benchmark('StringRepeat', false, false, 0,
StringRepeat, StringRepeatSetup, StringRepeatTearDown),
new Benchmark('StringStartsWith', false, false, 0,
StringStartsWith, StringWithSetup, StringWithTearDown),
new Benchmark('StringEndsWith', false, false, 0,
StringEndsWith, StringWithSetup, StringWithTearDown),
new Benchmark('StringContains', false, false, 0,
StringContains, StringContainsSetup, StringWithTearDown),
]);
var result;
var stringRepeatSource = "abc";
function StringRepeatSetup() {
result = undefined;
}
function StringRepeat() {
result = stringRepeatSource.repeat(500);
}
function StringRepeatTearDown() {
var expected = "";
for(var i = 0; i < 1000; i++) {
expected += stringRepeatSource;
}
return result === expected;
}
var str;
var substr;
function StringWithSetup() {
str = "abc".repeat(500);
substr = "abc".repeat(200);
result = undefined;
}
function StringWithTearDown() {
return !!result;
}
function StringStartsWith() {
result = str.startsWith(substr);
}
function StringEndsWith() {
result = str.endsWith(substr);
}
function StringContainsSetup() {
str = "def".repeat(100) + "abc".repeat(100) + "qqq".repeat(100);
substr = "abc".repeat(100);
}
function StringContains() {
result = str.contains(substr);
}

View File

@ -0,0 +1,27 @@
// 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('harmony-string.js');
var success = true;
function PrintResult(name, result) {
print(name + '-Strings(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 });