Commit 807fc144 authored by Sigurd Schneider's avatar Sigurd Schneider Committed by Commit Bot

[Turbofan] Add benchmark for String.prototype.charCodeAt

This also fixes benchmark scores for String.prototype.indexOf

Bug: v8:7127, v8:7092
Change-Id: Iee0f9689feb5923b300e253c267a6f32ffd4da20
Reviewed-on: https://chromium-review.googlesource.com/846739Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#50316}
parent 86abfd35
......@@ -2,17 +2,16 @@
// 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 BenchmarkSuite('StringIndexOfConstant', [5], [
new Benchmark('StringIndexOfConstant', true, false, 0,
StringIndexOfConstant),
]);
new BenchmarkSuite('StringIndexOfNonConstant', [1000], [
new BenchmarkSuite('StringIndexOfNonConstant', [5], [
new Benchmark('StringIndexOfNonConstant', true, false, 0,
StringIndexOfNonConstant),
]);
const N = 10 ** 6;
const subject = "aaaaaaaaaaaaaaaab";
const searches = ['a', 'b', 'c'];
......@@ -35,3 +34,36 @@ function StringIndexOfNonConstant() {
return sum;
}
new BenchmarkSuite('StringCharCodeAtConstant', [3], [
new Benchmark('StringIndexOfConstant', true, false, 0,
StringCharCodeAtConstant),
]);
new BenchmarkSuite('StringCharCodeAtNonConstant', [3], [
new Benchmark('StringIndexOfNonConstant', true, false, 0,
StringCharCodeAtNonConstant),
]);
const string = "qweruiplkjhgfdsazxccvbnm";
const indices = [1, 13, 32, 100, "xx"];
function StringCharCodeAtConstant() {
var sum = 0;
for (var j = 0; j < indices.length - 1; ++j) {
sum += string.charCodeAt(indices[j] | 0);
}
return sum;
}
function StringCharCodeAtNonConstant() {
var sum = 0;
for (var j = 0; j < indices.length - 1; ++j) {
sum += string.charCodeAt(indices[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