[Interpreter] Add js-perf-test benchmark for compare bytecode handlers.
Adds a micro benchmark in js-perf-test to measure the performance of compare bytecode handlers. Bug:v8:4280 Change-Id: Ic86d670f8f09147076a22cfeff2e1ec052afe20c Reviewed-on: https://chromium-review.googlesource.com/485522 Reviewed-by: Ross McIlroy <rmcilroy@chromium.org> Reviewed-by: Michael Achenbach <machenbach@chromium.org> Commit-Queue: Mythri Alle <mythria@chromium.org> Cr-Commit-Position: refs/heads/master@{#44843}
This commit is contained in:
parent
4531c865a9
commit
e480b2b29d
157
test/js-perf-test/BytecodeHandlers/compare.js
Normal file
157
test/js-perf-test/BytecodeHandlers/compare.js
Normal file
@ -0,0 +1,157 @@
|
||||
// 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('Smi-StrictEquals-True', SmiStrictEqualsTrue);
|
||||
addBenchmark('Smi-StrictEquals-False', SmiStrictEqualsFalse);
|
||||
addBenchmark('Number-StrictEquals-True', NumberStrictEqualsTrue);
|
||||
addBenchmark('Number-StrictEquals-False', NumberStrictEqualsFalse);
|
||||
addBenchmark('String-StrictEquals-True', StringStrictEqualsTrue);
|
||||
addBenchmark('String-StrictEquals-False', StringStrictEqualsFalse);
|
||||
addBenchmark('SmiString-StrictEquals', MixedStrictEquals);
|
||||
addBenchmark('Smi-Equals-True', SmiEqualsTrue);
|
||||
addBenchmark('Smi-Equals-False', SmiEqualsFalse);
|
||||
addBenchmark('Number-Equals-True', NumberEqualsTrue);
|
||||
addBenchmark('Number-Equals-False', NumberEqualsFalse);
|
||||
addBenchmark('String-Equals-True', StringEqualsTrue);
|
||||
addBenchmark('String-Equals-False', StringEqualsFalse);
|
||||
addBenchmark('SmiString-Equals', MixedEquals);
|
||||
addBenchmark('ObjectNull-Equals', ObjectEqualsNull);
|
||||
addBenchmark('Smi-RelationalCompare', SmiRelationalCompare);
|
||||
addBenchmark('Number-RelationalCompare', NumberRelationalCompare);
|
||||
addBenchmark('String-RelationalCompare', StringRelationalCompare);
|
||||
addBenchmark('SmiString-RelationalCompare', MixedRelationalCompare);
|
||||
|
||||
var null_object;
|
||||
|
||||
function strictEquals(a, b) {
|
||||
for (var i = 0; i < 1000; ++i) {
|
||||
a === b; a === b; a === b; a === b; a === b; a === b; a === b; a === b; a === b; a === b;
|
||||
a === b; a === b; a === b; a === b; a === b; a === b; a === b; a === b; a === b; a === b;
|
||||
a === b; a === b; a === b; a === b; a === b; a === b; a === b; a === b; a === b; a === b;
|
||||
a === b; a === b; a === b; a === b; a === b; a === b; a === b; a === b; a === b; a === b;
|
||||
a === b; a === b; a === b; a === b; a === b; a === b; a === b; a === b; a === b; a === b;
|
||||
a === b; a === b; a === b; a === b; a === b; a === b; a === b; a === b; a === b; a === b;
|
||||
a === b; a === b; a === b; a === b; a === b; a === b; a === b; a === b; a === b; a === b;
|
||||
a === b; a === b; a === b; a === b; a === b; a === b; a === b; a === b; a === b; a === b;
|
||||
a === b; a === b; a === b; a === b; a === b; a === b; a === b; a === b; a === b; a === b;
|
||||
a === b; a === b; a === b; a === b; a === b; a === b; a === b; a === b; a === b; a === b;
|
||||
}
|
||||
}
|
||||
|
||||
function equals(a, b) {
|
||||
for (var i = 0; i < 1000; ++i) {
|
||||
a == b; a == b; a == b; a == b; a == b; a == b; a == b; a == b; a == b; a == b;
|
||||
a == b; a == b; a == b; a == b; a == b; a == b; a == b; a == b; a == b; a == b;
|
||||
a == b; a == b; a == b; a == b; a == b; a == b; a == b; a == b; a == b; a == b;
|
||||
a == b; a == b; a == b; a == b; a == b; a == b; a == b; a == b; a == b; a == b;
|
||||
a == b; a == b; a == b; a == b; a == b; a == b; a == b; a == b; a == b; a == b;
|
||||
a == b; a == b; a == b; a == b; a == b; a == b; a == b; a == b; a == b; a == b;
|
||||
a == b; a == b; a == b; a == b; a == b; a == b; a == b; a == b; a == b; a == b;
|
||||
a == b; a == b; a == b; a == b; a == b; a == b; a == b; a == b; a == b; a == b;
|
||||
a == b; a == b; a == b; a == b; a == b; a == b; a == b; a == b; a == b; a == b;
|
||||
a == b; a == b; a == b; a == b; a == b; a == b; a == b; a == b; a == b; a == b;
|
||||
}
|
||||
}
|
||||
|
||||
// Relational comparison handlers are similar, so use one benchmark to measure
|
||||
// all of them.
|
||||
function relationalCompare(a, b) {
|
||||
for (var i = 0; i < 1000; ++i) {
|
||||
a > b; a > b; a > b; a > b; a > b; a > b; a > b; a > b; a > b; a > b;
|
||||
a > b; a > b; a > b; a > b; a > b; a > b; a > b; a > b; a > b; a > b;
|
||||
a > b; a > b; a > b; a > b; a > b; a > b; a > b; a > b; a > b; a > b;
|
||||
a >= b; a >= b; a >= b; a >= b; a >= b; a >= b; a >= b; a >= b; a >= b; a >= b;
|
||||
a >= b; a >= b; a >= b; a >= b; a >= b; a >= b; a >= b; a >= b; a >= b; a >= b;
|
||||
a >= b; a >= b; a >= b; a >= b; a >= b; a >= b; a >= b; a >= b; a >= b; a >= b;
|
||||
a < b; a < b; a < b; a < b; a < b; a < b; a < b; a < b; a < b; a < b;
|
||||
a < b; a < b; a < b; a < b; a < b; a < b; a < b; a < b; a < b; a < b;
|
||||
a < b; a < b; a < b; a < b; a < b; a < b; a < b; a < b; a < b; a < b;
|
||||
a <= b; a <= b; a <= b; a <= b; a <= b; a <= b; a <= b; a <= b; a <= b; a <= b;
|
||||
a <= b; a <= b; a <= b; a <= b; a <= b; a <= b; a <= b; a <= b; a <= b; a <= b;
|
||||
a <= b; a <= b; a <= b; a <= b; a <= b; a <= b; a <= b; a <= b; a <= b; a <= b;
|
||||
}
|
||||
}
|
||||
|
||||
function SmiStrictEqualsFalse() {
|
||||
strictEquals(10, 20);
|
||||
}
|
||||
|
||||
function SmiStrictEqualsTrue() {
|
||||
strictEquals(10, 10);
|
||||
}
|
||||
|
||||
function NumberStrictEqualsFalse() {
|
||||
strictEquals(0.3333, 0.3334);
|
||||
}
|
||||
|
||||
function NumberStrictEqualsTrue() {
|
||||
strictEquals(0.3333, 0.3333);
|
||||
}
|
||||
|
||||
function StringStrictEqualsFalse() {
|
||||
strictEquals("abc", "def");
|
||||
}
|
||||
|
||||
function StringStrictEqualsTrue() {
|
||||
strictEquals("abc", "abc");
|
||||
}
|
||||
|
||||
function MixedStrictEquals() {
|
||||
strictEquals(10, "10");
|
||||
}
|
||||
|
||||
function SmiEqualsFalse() {
|
||||
strictEquals(10, 20);
|
||||
}
|
||||
|
||||
function SmiEqualsTrue() {
|
||||
strictEquals(10, 10);
|
||||
}
|
||||
|
||||
function NumberEqualsFalse() {
|
||||
strictEquals(0.3333, 0.3334);
|
||||
}
|
||||
|
||||
function NumberEqualsTrue() {
|
||||
strictEquals(0.3333, 0.3333);
|
||||
}
|
||||
|
||||
function StringEqualsFalse() {
|
||||
strictEquals("abc", "def");
|
||||
}
|
||||
|
||||
function StringEqualsTrue() {
|
||||
strictEquals("abc", "abc");
|
||||
}
|
||||
|
||||
function MixedEquals() {
|
||||
strictEquals(10, "10");
|
||||
}
|
||||
|
||||
function ObjectEqualsNull(null_object) {
|
||||
strictEquals(null_object, null);
|
||||
}
|
||||
|
||||
function SmiRelationalCompare() {
|
||||
relationalCompare(10, 20);
|
||||
}
|
||||
|
||||
function NumberRelationalCompare() {
|
||||
relationalCompare(0.3333, 0.3334);
|
||||
}
|
||||
|
||||
function StringRelationalCompare() {
|
||||
relationalCompare("abc", "def");
|
||||
}
|
||||
|
||||
function MixedRelationalCompare() {
|
||||
relationalCompare(10, "10");
|
||||
}
|
29
test/js-perf-test/BytecodeHandlers/run.js
Normal file
29
test/js-perf-test/BytecodeHandlers/run.js
Normal file
@ -0,0 +1,29 @@
|
||||
// Copyright 2014 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('compare.js');
|
||||
|
||||
var success = true;
|
||||
|
||||
function PrintResult(name, result) {
|
||||
print(name + '-BytecodeHandler(Score): ' + result);
|
||||
}
|
||||
|
||||
function PrintStep(name) {}
|
||||
|
||||
function PrintError(name, error) {
|
||||
PrintResult(name, error);
|
||||
success = false;
|
||||
}
|
||||
|
||||
|
||||
BenchmarkSuite.config.doWarmup = undefined;
|
||||
BenchmarkSuite.config.doDeterministic = undefined;
|
||||
|
||||
BenchmarkSuite.RunSuites({ NotifyResult: PrintResult,
|
||||
NotifyError: PrintError,
|
||||
NotifyStep: PrintStep });
|
@ -413,6 +413,28 @@
|
||||
{"name": "BasicImport"},
|
||||
{"name": "BasicNamespace"}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "BytecodeHandlers",
|
||||
"path": ["BytecodeHandlers"],
|
||||
"main": "run.js",
|
||||
"resources": [ "compare.js" ],
|
||||
"flags": [ "--no-opt" ],
|
||||
"results_regexp": "^%s\\-BytecodeHandler\\(Score\\): (.+)$",
|
||||
"tests": [
|
||||
{"name": "Smi-StrictEquals"},
|
||||
{"name": "Number-StrictEquals"},
|
||||
{"name": "String-StrictEquals"},
|
||||
{"name": "SmiString-StrictEquals"},
|
||||
{"name": "Smi-Equals"},
|
||||
{"name": "Number-Equals"},
|
||||
{"name": "String-Equals"},
|
||||
{"name": "SmiString-Equals"},
|
||||
{"name": "Smi-RelationalCompare"},
|
||||
{"name": "Number-RelationalCompare"},
|
||||
{"name": "String-RelationalCompare"},
|
||||
{"name": "SmiString-RelationalCompare"}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user