[js-perf-test] Add perf test for BigInt's ToBoolean
This cl also adds a separate test suite for BigInts Bug: v8:9213 Change-Id: I57271eed0f9c33a543fe15550964d55e3df3e963 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1596728 Commit-Queue: Nico Hartmann <nicohartmann@google.com> Reviewed-by: Georg Neis <neis@chromium.org> Reviewed-by: Sigurd Schneider <sigurds@chromium.org> Reviewed-by: Tamer Tas <tmrts@chromium.org> Cr-Commit-Position: refs/heads/master@{#61282}
This commit is contained in:
parent
a7826ddf8f
commit
20795b18f0
28
test/js-perf-test/BigInt/run.js
Normal file
28
test/js-perf-test/BigInt/run.js
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
load('../base.js');
|
||||||
|
load('to-boolean.js');
|
||||||
|
|
||||||
|
|
||||||
|
var success = true;
|
||||||
|
|
||||||
|
function PrintResult(name, result) {
|
||||||
|
print(name + '-BigInt(Score): ' + result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function PrintError(name, error) {
|
||||||
|
PrintResult(name, error);
|
||||||
|
success = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BenchmarkSuite.config.doWarmup = undefined;
|
||||||
|
BenchmarkSuite.config.doDeterministic = undefined;
|
||||||
|
|
||||||
|
BenchmarkSuite.RunSuites({ NotifyResult: PrintResult,
|
||||||
|
NotifyError: PrintError });
|
44
test/js-perf-test/BigInt/to-boolean.js
Normal file
44
test/js-perf-test/BigInt/to-boolean.js
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
const ITERATIONS = 10000;
|
||||||
|
|
||||||
|
// 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', [1000], [
|
||||||
|
new Benchmark('Prevent-Inline-Dummy', true, false, 0, () => {})
|
||||||
|
]);
|
||||||
|
|
||||||
|
new BenchmarkSuite('BigInt-ToBoolean', [1000], [
|
||||||
|
new Benchmark('BigInt-ToBoolean', true, false, 0, TestToBoolean),
|
||||||
|
]);
|
||||||
|
|
||||||
|
new BenchmarkSuite('BigInt-BooleanConstructor', [1000], [
|
||||||
|
new Benchmark('BigInt-BooleanConstructor', true, false, 0, TestBooleanConstructor),
|
||||||
|
]);
|
||||||
|
|
||||||
|
|
||||||
|
function TestBooleanConstructor() {
|
||||||
|
let kl = true;
|
||||||
|
for (let i = 0; i < ITERATIONS; ++i) {
|
||||||
|
// Store to a variable to prevent elimination.
|
||||||
|
// Keep a depedency on the loop counter to prevent hoisting.
|
||||||
|
kl = Boolean(i % 2 == 0 ? 42n : 32n);
|
||||||
|
}
|
||||||
|
return kl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function TestToBoolean() {
|
||||||
|
let kl = true;
|
||||||
|
for (let i = 0; i < ITERATIONS; ++i) {
|
||||||
|
// Store to a variable to prevent elimination.
|
||||||
|
// Keep a depedency on the loop counter to prevent hoisting.
|
||||||
|
kl = (i % 2 == 0 ? 42n : 32n) ? true : false;
|
||||||
|
}
|
||||||
|
return kl;
|
||||||
|
}
|
@ -45,6 +45,19 @@
|
|||||||
{"name": "WeakSet-Constructor"}
|
{"name": "WeakSet-Constructor"}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "BigInt",
|
||||||
|
"path": ["BigInt"],
|
||||||
|
"main": "run.js",
|
||||||
|
"resources": [
|
||||||
|
"to-boolean.js"
|
||||||
|
],
|
||||||
|
"results_regexp": "^%s\\-BigInt\\(Score\\): (.+)$",
|
||||||
|
"tests": [
|
||||||
|
{ "name": "BigInt-ToBoolean" },
|
||||||
|
{ "name": "BigInt-BooleanConstructor" }
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "TypedArrays",
|
"name": "TypedArrays",
|
||||||
"path": ["TypedArrays"],
|
"path": ["TypedArrays"],
|
||||||
|
Loading…
Reference in New Issue
Block a user