v8/test/js-perf-test/Modules/basic-export.js
Jakob Kummerow 693e8ac59f [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: Adam Klein <adamk@chromium.org>
Reviewed-by: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47686}
2017-08-29 16:50:44 +00:00

59 lines
1.3 KiB
JavaScript

// Copyright 2017 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.
export let value = 0;
export function set(x) { value = x };
export let a0 = 0;
export let a1 = 1;
export let a2 = 2;
export let a3 = 3;
export let a4 = 4;
export let a5 = 5;
export let a6 = 6;
export let a7 = 7;
export let a8 = 8;
export let a9 = 9;
export let a10 = 10;
export let a11 = 11;
export let a12 = 12;
export let a13 = 13;
export let a14 = 14;
export let a15 = 15;
export let a16 = 16;
export let a17 = 17;
export let a18 = 18;
export let a19 = 19;
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;
set(0);
}