Commit cc7ac98b authored by Z Duong Nguyen-Huu's avatar Z Duong Nguyen-Huu Committed by Commit Bot

add micro-benchmark for object freeze with tagged template

Bug: v8:6831
Change-Id: I67e4d9f39576a4067dad59b18b3b4bf04bcdcb99
Reviewed-on: https://chromium-review.googlesource.com/c/1461166
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59486}
parent ba1d0f25
......@@ -1373,6 +1373,20 @@
{"name": "toLocaleString"}
]
},
{
"name": "ObjectFreeze",
"path": ["ObjectFreeze"],
"main": "run.js",
"flags": [],
"resources": [
"tagged-template.js"
],
"results_regexp": "^%s\\-Numbers\\(Score\\): (.+)$",
"tests": [
{"name": "TaggedTemplate"},
{"name": "TaggedTemplateLoose"}
]
},
{
"name": "TurboFan",
"path": ["TurboFan"],
......
// Copyright 2018 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.
load('../base.js');
load('tagged-template.js');
function PrintResult(name, result) {
console.log(name);
console.log(name + '-Numbers(Score): ' + result);
}
function PrintError(name, error) {
PrintResult(name, error);
}
BenchmarkSuite.config.doWarmup = undefined;
BenchmarkSuite.config.doDeterministic = undefined;
BenchmarkSuite.RunSuites({ NotifyResult: PrintResult,
NotifyError: PrintError });
// Copyright 2019 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 tag(strings, ...values) {
let a = 0;
for (let i = 0; i < strings.length; ++i) a += strings[i].length;
return a;
}
function driver(n) {
let result = 0;
for (let i = 0; i < n; ++i) {
result += tag`${"Hello"} ${"cruel"} ${"slow"} ${"world"}!\n`;
result += tag`${"Why"} ${"is"} ${"this"} ${"so"} ${"damn"} ${"slow"}?!\n`;
}
return result;
}
function TaggedTemplate() {
driver(1e4);
}
function TaggedTemplateWarmUp() {
driver(1e1);
driver(1e2);
driver(1e3);
}
createSuite('TaggedTemplate', 10, TaggedTemplate, TaggedTemplateWarmUp);
var _templateObject = _taggedTemplateLiteralLoose(
["", " ", " ", " ", "!\n"],
["", " ", " ", " ", "!\\n"]
),
_templateObject2 = _taggedTemplateLiteralLoose(
["", " ", " ", " ", " ", " ", "?!\n"],
["", " ", " ", " ", " ", " ", "?!\\n"]
);
function _taggedTemplateLiteralLoose(strings, raw) {
strings.raw = raw;
return strings;
}
function driverLoose(n) {
var result = 0;
for (var i = 0; i < n; ++i) {
result += tag(_templateObject, "Hello", "cruel", "slow", "world");
result += tag(_templateObject2, "Why", "is", "this", "so", "damn", "slow");
}
return result;
}
function TaggedTemplateLoose() {
driverLoose(1e4);
}
function TaggedTemplateLooseWarmUp() {
driverLoose(1e1);
driverLoose(1e2);
driverLoose(1e3);
}
createSuite('TaggedTemplateLoose', 10, TaggedTemplateLoose, TaggedTemplateLooseWarmUp);
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