Commit 3f31ffd0 authored by Nico Hartmann's avatar Nico Hartmann Committed by V8 LUCI CQ

BigInt.asIntN benchmark

Bug: v8:9407
Change-Id: Icc3130a028003f146e733b13b05568b434b530fe
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3218153
Auto-Submit: Nico Hartmann <nicohartmann@chromium.org>
Reviewed-by: 's avatarMaya Lekova <mslekova@chromium.org>
Commit-Queue: Maya Lekova <mslekova@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77344}
parent 6b00c94c
// Copyright 2021 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";
d8.file.execute('bigint-util.js');
let random_bigints = [];
// 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', [10000], [
new Benchmark('Prevent-Inline-Dummy', true, false, 0, () => {})
]);
[32, 64, 128, 256].forEach((d) => {
new BenchmarkSuite(`AsInt64-${d}`, [1000], [
new Benchmark(`AsInt64-${d}`, true, false, 0, TestAsInt64,
() => SetUpTestAsIntN(d))
]);
});
[32, 64, 128, 256].forEach((d) => {
new BenchmarkSuite(`AsInt32-${d}`, [1000], [
new Benchmark(`AsInt32-${d}`, true, false, 0, TestAsInt32,
() => SetUpTestAsIntN(d))
]);
});
[32, 64, 128, 256].forEach((d) => {
new BenchmarkSuite(`AsInt8-${d}`, [1000], [
new Benchmark(`AsInt8-${d}`, true, false, 0, TestAsInt8,
() => SetUpTestAsIntN(d))
]);
});
function SetUpTestAsIntN(d) {
random_bigints = [
RandomBigIntWithBits(d),
RandomBigIntWithBits(d),
RandomBigIntWithBits(d),
RandomBigIntWithBits(d),
RandomBigIntWithBits(d),
RandomBigIntWithBits(d),
RandomBigIntWithBits(d),
RandomBigIntWithBits(d)
];
}
function TestAsInt64() {
let result = 0n;
for (let i = 0; i < TEST_ITERATIONS; ++i) {
result = BigInt.asIntN(64, random_bigints[i % 8]);
}
return result;
}
function TestAsInt32() {
let result = 0n;
for (let i = 0; i < TEST_ITERATIONS; ++i) {
result = BigInt.asIntN(32, random_bigints[i % 8]);
}
return result;
}
function TestAsInt8() {
let result = 0n;
for (let i = 0; i < TEST_ITERATIONS; ++i) {
result = BigInt.asIntN(8, random_bigints[i % 8]);
}
return result;
}
......@@ -157,6 +157,27 @@
{ "name": "AsUint8-128" },
{ "name": "AsUint8-256" }
]
},
{
"name": "AsIntN",
"main": "run.js",
"resources": ["as-int-n.js", "bigint-util.js"],
"test_flags": ["as-int-n"],
"results_regexp": "^BigInt\\-%s\\(Score\\): (.+)$",
"tests": [
{ "name": "AsInt64-32" },
{ "name": "AsInt64-64" },
{ "name": "AsInt64-128" },
{ "name": "AsInt64-256" },
{ "name": "AsInt32-32" },
{ "name": "AsInt32-64" },
{ "name": "AsInt32-128" },
{ "name": "AsInt32-256" },
{ "name": "AsInt8-32" },
{ "name": "AsInt8-64" },
{ "name": "AsInt8-128" },
{ "name": "AsInt8-256" }
]
}
]
},
......
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