[js-perf-test] Add regression benchmark

This CL adds a regression benchmark for a fast-path of
String.p.charCodeAt, which is important for node.js.

Bug: v8:7326
Change-Id: I54efaa2988c595dd40e6a55a3464b3ee7de6f07b
Reviewed-on: https://chromium-review.googlesource.com/942885
Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51654}
This commit is contained in:
Sigurd Schneider 2018-03-01 13:48:23 +01:00 committed by Commit Bot
parent ac9b1ebe7c
commit 80447cff70
2 changed files with 20 additions and 1 deletions

View File

@ -221,7 +221,8 @@
{"name": "StringEndsWith"},
{"name": "StringIncludes"},
{"name": "StringFromCodePoint"},
{"name": "StringCodePointAt"}
{"name": "StringCodePointAt"},
{"name": "StringCodePointAtSum"}
]
},
{

View File

@ -32,6 +32,11 @@ new BenchmarkSuite('StringCodePointAt', [1000], [
CodePointAt, CodePointAtSetup, CodePointAtTearDown),
]);
new BenchmarkSuite('StringCodePointAtSum', [100000], [
new Benchmark('StringCodePointAtSum', false, true, 3,
CodePointAtSum, CodePointAtSumSetup),
]);
var result;
@ -125,3 +130,16 @@ function CodePointAt() {
function CodePointAtTearDown() {
return result === (MAX_CODE_POINT / K) * ((MAX_CODE_POINT / K) + 1) / 2;
}
var payload;
function CodePointAtSumSetup() {
payload = "abcdefghijklmnopqrstuvwxyz";
for(var j = 0; j < 16; ++j) payload += payload;
}
function CodePointAtSum() {
var c = 0;
for(j=payload.length-1; j >=0; --j) c+=payload.charCodeAt(j);
return c;
}