From e505b7a1598e2702e96da1b8bf64eae2d451afc4 Mon Sep 17 00:00:00 2001 From: Soreine Date: Thu, 3 Nov 2016 13:19:21 +0100 Subject: [PATCH] Remove ludicrous amount of setup work that was needed to prevent memoization --- perf/index.js | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/perf/index.js b/perf/index.js index 10497782e..2551c0817 100644 --- a/perf/index.js +++ b/perf/index.js @@ -22,6 +22,8 @@ const readMetadata = require('read-metadata') const { Raw } = require('..') const { resolve } = require('path') +window.__NO_MEMOIZE = true + const DEFAULT_BENCHMARK = { setup(state) { return state }, run(state) {} @@ -95,27 +97,19 @@ function runBenchmarks() { // memoization between calls to `fn` const scope = global.getScope() - let states = [] - let numberOfExecution = this.count - while (numberOfExecution--) { - states.push( - // Each benchmark is given the chance to do its own setup - scope.benchmark.setup( - scope.Raw.deserialize(scope.input, { terse: true }) - ) - ) - } - - let stateIndex = 0 + const state = + // Each benchmark is given the chance to do its own setup + scope.benchmark.setup( + scope.Raw.deserialize(scope.input, { terse: true }) + ) }, // Because of the way BenchmarkJS compiles the functions, // the variables declared in `setup` are visible to `fn` fn() { - scope.benchmark.run(states[stateIndex]) // eslint-disable-line no-undef + scope.benchmark.run(state) // eslint-disable-line no-undef // Next call will use another State instance - stateIndex++ // eslint-disable-line no-undef } })) }