Commit 5acdb557 authored by Ross McIlroy's avatar Ross McIlroy Committed by Commit Bot

[Interpreter] Add micro-benchmarks for string concatentation.

BUG=v8:6243

Change-Id: Ia6dfa407591d1b06d5b014627bb44413540aecb3
Reviewed-on: https://chromium-review.googlesource.com/516984Reviewed-by: 's avatarMythri Alle <mythria@chromium.org>
Commit-Queue: Ross McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#45542}
parent efc9d543
......@@ -6,6 +6,7 @@
load('../base.js');
load('compare.js');
load('string-concat.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.
function addBenchmark(name, test) {
new BenchmarkSuite(name, [1000],
[
new Benchmark(name, false, false, 0, test)
]);
}
addBenchmark('ShortString-StringConcat-2', ShortStringConcat2);
addBenchmark('ShortString-StringConcat-3', ShortStringConcat3);
addBenchmark('ShortString-StringConcat-5', ShortStringConcat5);
addBenchmark('ShortString-StringConcat-10', ShortStringConcat10);
addBenchmark('LongString-StringConcat-2', LongStringConcat2);
addBenchmark('LongString-StringConcat-3', LongStringConcat3);
addBenchmark('LongString-StringConcat-5', LongStringConcat5);
addBenchmark('LongString-StringConcat-10', LongStringConcat10);
addBenchmark('NumberString-StringConcat-2', NumberStringConcat2);
addBenchmark('NumberString-StringConcat-3', NumberStringConcat3);
addBenchmark('NumberString-StringConcat-5', NumberStringConcat5);
addBenchmark('NumberString-StringConcat-10', NumberStringConcat10);
function stringConcat2(a) {
for (var i = 0; i < 100; ++i) {
"s" + a; "s" + a; "s" + a; "s" + a; "s" + a; "s" + a; "s" + a; "s" + a; "s" + a; "s" + a;
"s" + a; "s" + a; "s" + a; "s" + a; "s" + a; "s" + a; "s" + a; "s" + a; "s" + a; "s" + a;
"s" + a; "s" + a; "s" + a; "s" + a; "s" + a; "s" + a; "s" + a; "s" + a; "s" + a; "s" + a;
"s" + a; "s" + a; "s" + a; "s" + a; "s" + a; "s" + a; "s" + a; "s" + a; "s" + a; "s" + a;
"s" + a; "s" + a; "s" + a; "s" + a; "s" + a; "s" + a; "s" + a; "s" + a; "s" + a; "s" + a;
"s" + a; "s" + a; "s" + a; "s" + a; "s" + a; "s" + a; "s" + a; "s" + a; "s" + a; "s" + a;
"s" + a; "s" + a; "s" + a; "s" + a; "s" + a; "s" + a; "s" + a; "s" + a; "s" + a; "s" + a;
"s" + a; "s" + a; "s" + a; "s" + a; "s" + a; "s" + a; "s" + a; "s" + a; "s" + a; "s" + a;
"s" + a; "s" + a; "s" + a; "s" + a; "s" + a; "s" + a; "s" + a; "s" + a; "s" + a; "s" + a;
"s" + a; "s" + a; "s" + a; "s" + a; "s" + a; "s" + a; "s" + a; "s" + a; "s" + a; "s" + a;
}
}
function stringConcat3(a, b) {
for (var i = 0; i < 100; ++i) {
"s" + a + b; "s" + a + b; "s" + a + b; "s" + a + b; "s" + a + b;
"s" + a + b; "s" + a + b; "s" + a + b; "s" + a + b; "s" + a + b;
"s" + a + b; "s" + a + b; "s" + a + b; "s" + a + b; "s" + a + b;
"s" + a + b; "s" + a + b; "s" + a + b; "s" + a + b; "s" + a + b;
"s" + a + b; "s" + a + b; "s" + a + b; "s" + a + b; "s" + a + b;
"s" + a + b; "s" + a + b; "s" + a + b; "s" + a + b; "s" + a + b;
"s" + a + b; "s" + a + b; "s" + a + b; "s" + a + b; "s" + a + b;
"s" + a + b; "s" + a + b; "s" + a + b; "s" + a + b; "s" + a + b;
"s" + a + b; "s" + a + b; "s" + a + b; "s" + a + b; "s" + a + b;
"s" + a + b; "s" + a + b; "s" + a + b; "s" + a + b; "s" + a + b;
"s" + a + b; "s" + a + b; "s" + a + b; "s" + a + b; "s" + a + b;
"s" + a + b; "s" + a + b; "s" + a + b; "s" + a + b; "s" + a + b;
"s" + a + b; "s" + a + b; "s" + a + b; "s" + a + b; "s" + a + b;
"s" + a + b; "s" + a + b; "s" + a + b; "s" + a + b; "s" + a + b;
"s" + a + b; "s" + a + b; "s" + a + b; "s" + a + b; "s" + a + b;
"s" + a + b; "s" + a + b; "s" + a + b; "s" + a + b; "s" + a + b;
"s" + a + b; "s" + a + b; "s" + a + b; "s" + a + b; "s" + a + b;
"s" + a + b; "s" + a + b; "s" + a + b; "s" + a + b; "s" + a + b;
"s" + a + b; "s" + a + b; "s" + a + b; "s" + a + b; "s" + a + b;
"s" + a + b; "s" + a + b; "s" + a + b; "s" + a + b; "s" + a + b;
}
}
function stringConcat5(a, b, c, d) {
for (var i = 0; i < 100; ++i) {
"s" + a + b + c + d; "s" + a + b + c + d; "s" + a + b + c + d; "s" + a + b + c + d; "s" + a + b + c + d;
"s" + a + b + c + d; "s" + a + b + c + d; "s" + a + b + c + d; "s" + a + b + c + d; "s" + a + b + c + d;
"s" + a + b + c + d; "s" + a + b + c + d; "s" + a + b + c + d; "s" + a + b + c + d; "s" + a + b + c + d;
"s" + a + b + c + d; "s" + a + b + c + d; "s" + a + b + c + d; "s" + a + b + c + d; "s" + a + b + c + d;
"s" + a + b + c + d; "s" + a + b + c + d; "s" + a + b + c + d; "s" + a + b + c + d; "s" + a + b + c + d;
"s" + a + b + c + d; "s" + a + b + c + d; "s" + a + b + c + d; "s" + a + b + c + d; "s" + a + b + c + d;
"s" + a + b + c + d; "s" + a + b + c + d; "s" + a + b + c + d; "s" + a + b + c + d; "s" + a + b + c + d;
"s" + a + b + c + d; "s" + a + b + c + d; "s" + a + b + c + d; "s" + a + b + c + d; "s" + a + b + c + d;
"s" + a + b + c + d; "s" + a + b + c + d; "s" + a + b + c + d; "s" + a + b + c + d; "s" + a + b + c + d;
"s" + a + b + c + d; "s" + a + b + c + d; "s" + a + b + c + d; "s" + a + b + c + d; "s" + a + b + c + d;
"s" + a + b + c + d; "s" + a + b + c + d; "s" + a + b + c + d; "s" + a + b + c + d; "s" + a + b + c + d;
"s" + a + b + c + d; "s" + a + b + c + d; "s" + a + b + c + d; "s" + a + b + c + d; "s" + a + b + c + d;
"s" + a + b + c + d; "s" + a + b + c + d; "s" + a + b + c + d; "s" + a + b + c + d; "s" + a + b + c + d;
"s" + a + b + c + d; "s" + a + b + c + d; "s" + a + b + c + d; "s" + a + b + c + d; "s" + a + b + c + d;
"s" + a + b + c + d; "s" + a + b + c + d; "s" + a + b + c + d; "s" + a + b + c + d; "s" + a + b + c + d;
"s" + a + b + c + d; "s" + a + b + c + d; "s" + a + b + c + d; "s" + a + b + c + d; "s" + a + b + c + d;
"s" + a + b + c + d; "s" + a + b + c + d; "s" + a + b + c + d; "s" + a + b + c + d; "s" + a + b + c + d;
"s" + a + b + c + d; "s" + a + b + c + d; "s" + a + b + c + d; "s" + a + b + c + d; "s" + a + b + c + d;
"s" + a + b + c + d; "s" + a + b + c + d; "s" + a + b + c + d; "s" + a + b + c + d; "s" + a + b + c + d;
"s" + a + b + c + d; "s" + a + b + c + d; "s" + a + b + c + d; "s" + a + b + c + d; "s" + a + b + c + d;
}
}
function stringConcat10(a, b, c, d, e, f, g, h, i) {
for (var j = 0; j < 100; ++j) {
"s" + a + b + c + d + e + f + g + h + i; "s" + a + b + c + d + e + f + g + h + i;
"s" + a + b + c + d + e + f + g + h + i; "s" + a + b + c + d + e + f + g + h + i;
"s" + a + b + c + d + e + f + g + h + i; "s" + a + b + c + d + e + f + g + h + i;
"s" + a + b + c + d + e + f + g + h + i; "s" + a + b + c + d + e + f + g + h + i;
"s" + a + b + c + d + e + f + g + h + i; "s" + a + b + c + d + e + f + g + h + i;
"s" + a + b + c + d + e + f + g + h + i; "s" + a + b + c + d + e + f + g + h + i;
"s" + a + b + c + d + e + f + g + h + i; "s" + a + b + c + d + e + f + g + h + i;
"s" + a + b + c + d + e + f + g + h + i; "s" + a + b + c + d + e + f + g + h + i;
"s" + a + b + c + d + e + f + g + h + i; "s" + a + b + c + d + e + f + g + h + i;
"s" + a + b + c + d + e + f + g + h + i; "s" + a + b + c + d + e + f + g + h + i;
"s" + a + b + c + d + e + f + g + h + i; "s" + a + b + c + d + e + f + g + h + i;
"s" + a + b + c + d + e + f + g + h + i; "s" + a + b + c + d + e + f + g + h + i;
"s" + a + b + c + d + e + f + g + h + i; "s" + a + b + c + d + e + f + g + h + i;
"s" + a + b + c + d + e + f + g + h + i; "s" + a + b + c + d + e + f + g + h + i;
"s" + a + b + c + d + e + f + g + h + i; "s" + a + b + c + d + e + f + g + h + i;
"s" + a + b + c + d + e + f + g + h + i; "s" + a + b + c + d + e + f + g + h + i;
"s" + a + b + c + d + e + f + g + h + i; "s" + a + b + c + d + e + f + g + h + i;
"s" + a + b + c + d + e + f + g + h + i; "s" + a + b + c + d + e + f + g + h + i;
"s" + a + b + c + d + e + f + g + h + i; "s" + a + b + c + d + e + f + g + h + i;
"s" + a + b + c + d + e + f + g + h + i; "s" + a + b + c + d + e + f + g + h + i;
"s" + a + b + c + d + e + f + g + h + i; "s" + a + b + c + d + e + f + g + h + i;
"s" + a + b + c + d + e + f + g + h + i; "s" + a + b + c + d + e + f + g + h + i;
"s" + a + b + c + d + e + f + g + h + i; "s" + a + b + c + d + e + f + g + h + i;
"s" + a + b + c + d + e + f + g + h + i; "s" + a + b + c + d + e + f + g + h + i;
"s" + a + b + c + d + e + f + g + h + i; "s" + a + b + c + d + e + f + g + h + i;
"s" + a + b + c + d + e + f + g + h + i; "s" + a + b + c + d + e + f + g + h + i;
"s" + a + b + c + d + e + f + g + h + i; "s" + a + b + c + d + e + f + g + h + i;
"s" + a + b + c + d + e + f + g + h + i; "s" + a + b + c + d + e + f + g + h + i;
"s" + a + b + c + d + e + f + g + h + i; "s" + a + b + c + d + e + f + g + h + i;
"s" + a + b + c + d + e + f + g + h + i; "s" + a + b + c + d + e + f + g + h + i;
"s" + a + b + c + d + e + f + g + h + i; "s" + a + b + c + d + e + f + g + h + i;
"s" + a + b + c + d + e + f + g + h + i; "s" + a + b + c + d + e + f + g + h + i;
"s" + a + b + c + d + e + f + g + h + i; "s" + a + b + c + d + e + f + g + h + i;
"s" + a + b + c + d + e + f + g + h + i; "s" + a + b + c + d + e + f + g + h + i;
"s" + a + b + c + d + e + f + g + h + i; "s" + a + b + c + d + e + f + g + h + i;
"s" + a + b + c + d + e + f + g + h + i; "s" + a + b + c + d + e + f + g + h + i;
"s" + a + b + c + d + e + f + g + h + i; "s" + a + b + c + d + e + f + g + h + i;
"s" + a + b + c + d + e + f + g + h + i; "s" + a + b + c + d + e + f + g + h + i;
"s" + a + b + c + d + e + f + g + h + i; "s" + a + b + c + d + e + f + g + h + i;
"s" + a + b + c + d + e + f + g + h + i; "s" + a + b + c + d + e + f + g + h + i;
"s" + a + b + c + d + e + f + g + h + i; "s" + a + b + c + d + e + f + g + h + i;
"s" + a + b + c + d + e + f + g + h + i; "s" + a + b + c + d + e + f + g + h + i;
"s" + a + b + c + d + e + f + g + h + i; "s" + a + b + c + d + e + f + g + h + i;
"s" + a + b + c + d + e + f + g + h + i; "s" + a + b + c + d + e + f + g + h + i;
"s" + a + b + c + d + e + f + g + h + i; "s" + a + b + c + d + e + f + g + h + i;
"s" + a + b + c + d + e + f + g + h + i; "s" + a + b + c + d + e + f + g + h + i;
"s" + a + b + c + d + e + f + g + h + i; "s" + a + b + c + d + e + f + g + h + i;
"s" + a + b + c + d + e + f + g + h + i; "s" + a + b + c + d + e + f + g + h + i;
"s" + a + b + c + d + e + f + g + h + i; "s" + a + b + c + d + e + f + g + h + i;
"s" + a + b + c + d + e + f + g + h + i; "s" + a + b + c + d + e + f + g + h + i;
}
}
function ShortStringConcat2() {
stringConcat2("a");
}
function ShortStringConcat3() {
stringConcat3("a", "b");
}
function ShortStringConcat5() {
stringConcat5("a", "b", "c", "d");
}
function ShortStringConcat10() {
stringConcat10("a", "b", "c", "d", "e", "f", "g", "h", "i");
}
function LongStringConcat2() {
stringConcat2("long string over consmin");
}
function LongStringConcat3() {
stringConcat3("long string ", "over consmin");
}
function LongStringConcat5() {
stringConcat5("long ", "string ", "over ", "consmin");
}
function LongStringConcat10() {
stringConcat10("long ", "string ", "over ", "consmin ", "long ", "string ",
"over ", "consmin", "done");
}
function NumberStringConcat2() {
stringConcat2(123.456);
}
function NumberStringConcat3() {
stringConcat3(1, 0.2345);
}
function NumberStringConcat5() {
stringConcat5(1, 2, 3, 4.5, 5.6);
}
function NumberStringConcat10() {
stringConcat10(10, 2345, 5e10, 3.14, 987654321, 21.56789, 2, 3, 4);
}
......@@ -394,7 +394,7 @@
"name": "BytecodeHandlers",
"path": ["BytecodeHandlers"],
"main": "run.js",
"resources": [ "compare.js" ],
"resources": [ "compare.js", "string-concat.js" ],
"flags": [ "--no-opt" ],
"results_regexp": "^%s\\-BytecodeHandler\\(Score\\): (.+)$",
"tests": [
......@@ -416,7 +416,19 @@
{"name": "Smi-RelationalCompare"},
{"name": "Number-RelationalCompare"},
{"name": "String-RelationalCompare"},
{"name": "SmiString-RelationalCompare"}
{"name": "SmiString-RelationalCompare"},
{"name": "ShortString-StringConcat-2"},
{"name": "ShortString-StringConcat-3"},
{"name": "ShortString-StringConcat-5"},
{"name": "ShortString-StringConcat-10"},
{"name": "LongString-StringConcat-2"},
{"name": "LongString-StringConcat-3"},
{"name": "LongString-StringConcat-5"},
{"name": "LongString-StringConcat-10"},
{"name": "NumberString-StringConcat-2"},
{"name": "NumberString-StringConcat-3"},
{"name": "NumberString-StringConcat-5"},
{"name": "NumberString-StringConcat-10"}
]
}
]
......
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