diff options
| author | Rich Trott <rtrott@gmail.com> | 2019-04-14 11:01:28 -0700 |
|---|---|---|
| committer | Rich Trott <rtrott@gmail.com> | 2019-04-14 11:01:28 -0700 |
| commit | 1c5452f1bfff0354ff2c6609cd301ffb5b9782c7 (patch) | |
| tree | 8cb97190d4b9368106fd541512ee4da39c61eb80 | |
| parent | d4e743169eac7680dbbb67b11c6362fb15ca5f9a (diff) | |
| download | node-new-trott-temp-wip-14-Apr-2019.tar.gz | |
| -rw-r--r-- | benchmark/common.js | 7 | ||||
| -rw-r--r-- | benchmark/compare.js | 9 |
2 files changed, 15 insertions, 1 deletions
diff --git a/benchmark/common.js b/benchmark/common.js index b4778d7193..71361bc8b6 100644 --- a/benchmark/common.js +++ b/benchmark/common.js @@ -103,6 +103,13 @@ Benchmark.prototype._queue = function(options) { queue.push({}); } + // Shuffle the queue. This mitigates the possibility of artifacts resulting from + // operating system throttling or caching. + // Ref: https://github.com/nodejs/node/pull/27081#issuecomment-479981874 + for (let i = queue.length - 1; i > 0; i--) { + const j = Math.floor(Math.random() * (i + 1)); + [queue[i], queue[j]] = [queue[j], queue[i]]; + } return queue; }; diff --git a/benchmark/compare.js b/benchmark/compare.js index bd7c4a95cb..0cc655cd93 100644 --- a/benchmark/compare.js +++ b/benchmark/compare.js @@ -50,7 +50,14 @@ for (const filename of benchmarks) { } } } -// queue.length = binary.length * runs * benchmarks.length + +// Shuffle the queue. This mitigates the possibility of artifacts resulting from +// operating system throttling or caching. +// Ref: https://github.com/nodejs/node/pull/27081#issuecomment-479981874 +for (let i = queue.length - 1; i > 0; i--) { + const j = Math.floor(Math.random() * (i + 1)); + [queue[i], queue[j]] = [queue[j], queue[i]]; +} // Print csv header console.log('"binary", "filename", "configuration", "rate", "time"'); |
