Commit 693e8ac5 authored by Jakob Kummerow's avatar Jakob Kummerow Committed by Commit Bot

[js-perf-tests] Fix Modules benchmarks

The score is computed based on how often the benchmark's function can
be run within one second. Simply importing a Module repeatedly doesn't
do any work, so to make the test score meaningful, we must wrap the
payload into a function that can be called explicitly for every run.

NOTRY=true

Bug: v8:1569
Change-Id: Iadaed6df1f1652d8860271e327c505f0b8f20c2d
Reviewed-on: https://chromium-review.googlesource.com/639396
Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47686}
parent 29208428
......@@ -26,7 +26,8 @@ export let a17 = 17;
export let a18 = 18;
export let a19 = 19;
for (let i = 0; i < iterations; ++i) {
export function bench() {
for (let i = 0; i < iterations; ++i) {
let accumulator = value;
accumulator += a0;
accumulator += a1;
......@@ -49,8 +50,9 @@ for (let i = 0; i < iterations; ++i) {
accumulator += a18;
accumulator += a19;
set(accumulator);
}
}
if (value !== 190 * iterations) throw new Error;
if (value !== 190 * iterations) throw new Error;
set(0);
set(0);
}
......@@ -25,7 +25,8 @@ import { value,
a18,
a19 } from "value.js";
for (let i = 0; i < iterations; ++i) {
export function bench() {
for (let i = 0; i < iterations; ++i) {
let accumulator = value;
accumulator += a0;
accumulator += a1;
......@@ -48,8 +49,9 @@ for (let i = 0; i < iterations; ++i) {
accumulator += a18;
accumulator += a19;
set(accumulator);
}
}
if (value !== 190 * iterations) throw new Error;
if (value !== 190 * iterations) throw new Error;
set(0);
set(0);
}
......@@ -3,7 +3,9 @@
// found in the LICENSE file.
import * as m from "value.js";
for (let i = 0; i < iterations; ++i) {
export function bench() {
for (let i = 0; i < iterations; ++i) {
let accumulator = m.value;
accumulator += m.a0;
accumulator += m.a1;
......@@ -26,8 +28,9 @@ for (let i = 0; i < iterations; ++i) {
accumulator += m.a18;
accumulator += m.a19;
m.set(accumulator);
}
}
if (m.value !== 190 * iterations) throw new Error;
if (m.value !== 190 * iterations) throw new Error;
m.set(0);
m.set(0);
}
......@@ -17,26 +17,26 @@ new BenchmarkSuite('BasicNamespace', [100], [
new Benchmark('BasicNamespace', false, false, 0, BasicNamespace)
]);
const iterations = 1000000;
const iterations = 10000;
function BasicExport() {
let success = false;
import("basic-export.js").then(_ => success = true);
import("basic-export.js").then(m => { m.bench(); success = true; });
%RunMicrotasks();
if (!success) throw new Error(666);
}
function BasicImport() {
let success = false;
import("basic-import.js").then(_ => success = true);
import("basic-import.js").then(m => { m.bench(); success = true; });
%RunMicrotasks();
if (!success) throw new Error(666);
}
function BasicNamespace() {
let success = false;
import("basic-namespace.js").then(_ => success = true);
import("basic-namespace.js").then(m => { m.bench(); success = true; });
%RunMicrotasks();
if (!success) throw new Error(666);
}
......
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