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,31 +26,33 @@ export let a17 = 17;
export let a18 = 18;
export let a19 = 19;
for (let i = 0; i < iterations; ++i) {
let accumulator = value;
accumulator += a0;
accumulator += a1;
accumulator += a2;
accumulator += a3;
accumulator += a4;
accumulator += a5;
accumulator += a6;
accumulator += a7;
accumulator += a8;
accumulator += a9;
accumulator += a10;
accumulator += a11;
accumulator += a12;
accumulator += a13;
accumulator += a14;
accumulator += a15;
accumulator += a16;
accumulator += a17;
accumulator += a18;
accumulator += a19;
set(accumulator);
}
export function bench() {
for (let i = 0; i < iterations; ++i) {
let accumulator = value;
accumulator += a0;
accumulator += a1;
accumulator += a2;
accumulator += a3;
accumulator += a4;
accumulator += a5;
accumulator += a6;
accumulator += a7;
accumulator += a8;
accumulator += a9;
accumulator += a10;
accumulator += a11;
accumulator += a12;
accumulator += a13;
accumulator += a14;
accumulator += a15;
accumulator += a16;
accumulator += a17;
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,31 +25,33 @@ import { value,
a18,
a19 } from "value.js";
for (let i = 0; i < iterations; ++i) {
let accumulator = value;
accumulator += a0;
accumulator += a1;
accumulator += a2;
accumulator += a3;
accumulator += a4;
accumulator += a5;
accumulator += a6;
accumulator += a7;
accumulator += a8;
accumulator += a9;
accumulator += a10;
accumulator += a11;
accumulator += a12;
accumulator += a13;
accumulator += a14;
accumulator += a15;
accumulator += a16;
accumulator += a17;
accumulator += a18;
accumulator += a19;
set(accumulator);
}
export function bench() {
for (let i = 0; i < iterations; ++i) {
let accumulator = value;
accumulator += a0;
accumulator += a1;
accumulator += a2;
accumulator += a3;
accumulator += a4;
accumulator += a5;
accumulator += a6;
accumulator += a7;
accumulator += a8;
accumulator += a9;
accumulator += a10;
accumulator += a11;
accumulator += a12;
accumulator += a13;
accumulator += a14;
accumulator += a15;
accumulator += a16;
accumulator += a17;
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,31 +3,34 @@
// found in the LICENSE file.
import * as m from "value.js";
for (let i = 0; i < iterations; ++i) {
let accumulator = m.value;
accumulator += m.a0;
accumulator += m.a1;
accumulator += m.a2;
accumulator += m.a3;
accumulator += m.a4;
accumulator += m.a5;
accumulator += m.a6;
accumulator += m.a7;
accumulator += m.a8;
accumulator += m.a9;
accumulator += m.a10;
accumulator += m.a11;
accumulator += m.a12;
accumulator += m.a13;
accumulator += m.a14;
accumulator += m.a15;
accumulator += m.a16;
accumulator += m.a17;
accumulator += m.a18;
accumulator += m.a19;
m.set(accumulator);
}
if (m.value !== 190 * iterations) throw new Error;
export function bench() {
for (let i = 0; i < iterations; ++i) {
let accumulator = m.value;
accumulator += m.a0;
accumulator += m.a1;
accumulator += m.a2;
accumulator += m.a3;
accumulator += m.a4;
accumulator += m.a5;
accumulator += m.a6;
accumulator += m.a7;
accumulator += m.a8;
accumulator += m.a9;
accumulator += m.a10;
accumulator += m.a11;
accumulator += m.a12;
accumulator += m.a13;
accumulator += m.a14;
accumulator += m.a15;
accumulator += m.a16;
accumulator += m.a17;
accumulator += m.a18;
accumulator += m.a19;
m.set(accumulator);
}
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