node/deps/v8/test/js-perf-test/Operators/abstract-equality.js
Michaël Zasso 12478684aa
deps: update V8 to 8.4.371.19
PR-URL: https://github.com/nodejs/node/pull/33579
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>
2020-07-13 14:41:41 +02:00

80 lines
2.0 KiB
JavaScript

// Copyright 2020 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.
const TEST_ITERATIONS = 100000;
// This dummy ensures that the feedback for benchmark.run() in the Measure
// function from base.js is not monomorphic, thereby preventing the benchmarks
// below from being inlined. This ensures consistent behavior and comparable
// results.
new BenchmarkSuite('Prevent-Inline-Dummy', [100000], [
new Benchmark('Prevent-Inline-Dummy', true, false, 0, () => {})
]);
new BenchmarkSuite('Equal-SmiNumber', [100000], [
new Benchmark('Equal-SmiNumber', true, false, 0, TestEqualSmiNumber, SetUp)
]);
new BenchmarkSuite('Equal-SmiOddball', [100000], [
new Benchmark('Equal-SmiOddball', true, false, 0, TestEqualSmiOddball, SetUp)
]);
new BenchmarkSuite('Equal-NumberOddball', [100000], [
new Benchmark('Equal-NumberOddball', true, false, 0, TestEqualNumberOddball,
SetUp)
]);
new BenchmarkSuite('Equal-OddballOddball', [100000], [
new Benchmark('Equal-OddballOddball', true, false, 0, TestEqualOddballOddball,
SetUp)
]);
let smis = [];
let numbers = [];
let oddballs = [];
function SetUp() {
for(let i = 0; i < TEST_ITERATIONS + 1; ++i) {
smis[i] = (i % 2 == 0) ? 42 : -42;
numbers[i] = (i % 2 == 0) ? 42.3 : -42.3;
oddballs[i] = (i % 2 == 0);
}
}
function TestEqualSmiNumber() {
let result = false;
for(let i = 0; i < TEST_ITERATIONS; ++i) {
result = result || (11 == numbers[i]);
}
return result;
}
function TestEqualSmiOddball() {
let result = false;
for(let i = 1; i < TEST_ITERATIONS; ++i) {
result = result || (smis[i] == false);
}
return result;
}
function TestEqualNumberOddball() {
let result = false;
for(let i = 1; i < TEST_ITERATIONS; ++i) {
result = result || (numbers[i] == false);
}
return result;
}
function TestEqualOddballOddball() {
let result = false;
for(let i = 0; i < TEST_ITERATIONS; ++i) {
result = result || (oddballs[i] == oddballs[i+1]);
}
return result;
}