Commit 80447cff authored by Sigurd Schneider's avatar Sigurd Schneider Committed by Commit Bot

[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/942885Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51654}
parent ac9b1ebe
......@@ -221,7 +221,8 @@
{"name": "StringEndsWith"},
{"name": "StringIncludes"},
{"name": "StringFromCodePoint"},
{"name": "StringCodePointAt"}
{"name": "StringCodePointAt"},
{"name": "StringCodePointAtSum"}
]
},
{
......
......@@ -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;
}
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