Commit 5e18f849 authored by Sigurd Schneider's avatar Sigurd Schneider Committed by Commit Bot

[turbofan] Add benchmarks for String.indexOf

Bug: v8:7127, v8:6270
Change-Id: Ic35a9b7a5145115736934b0c7de6ace26e9c0e51
Reviewed-on: https://chromium-review.googlesource.com/832966
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#50191}
parent ad126d46
......@@ -180,13 +180,15 @@
"name": "Strings",
"path": ["Strings"],
"main": "run.js",
"resources": ["harmony-string.js"],
"resources": ["harmony-string.js", "string-indexof.js"],
"results_regexp": "^%s\\-Strings\\(Score\\): (.+)$",
"run_count": 1,
"timeout": 240,
"timeout_arm": 420,
"tests": [
{"name": "StringFunctions"}
{"name": "StringFunctions"},
{"name": "StringIndexOfConstant"},
{"name": "StringIndexOfNonConstant"}
]
},
{
......
......@@ -5,6 +5,7 @@
load('../base.js');
load('harmony-string.js');
load('string-indexof.js');
var success = true;
......
// 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.
new BenchmarkSuite('StringIndexOfConstant', [1000], [
new Benchmark('StringIndexOfConstant', true, false, 0,
StringIndexOfConstant),
]);
new BenchmarkSuite('StringIndexOfNonConstant', [1000], [
new Benchmark('StringIndexOfNonConstant', true, false, 0,
StringIndexOfNonConstant),
]);
const N = 10 ** 6;
const subject = "aaaaaaaaaaaaaaaab";
const searches = ['a', 'b', 'c'];
function StringIndexOfConstant() {
var sum = 0;
for (var j = 0; j < searches.length; ++j) {
sum += subject.indexOf("" + searches[j]);
}
return sum;
}
function StringIndexOfNonConstant() {
var sum = 0;
for (var j = 0; j < searches.length; ++j) {
sum += subject.indexOf(searches[j]);
}
return sum;
}
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