diff options
author | Ruben Bridgewater <ruben@bridgewater.de> | 2018-12-30 00:26:36 +0100 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2019-03-05 01:22:22 +0100 |
commit | 038a1a489d6d0a4d5c075611943b3c7c08f0e22a (patch) | |
tree | 6fce510b11ad12351d9c23dd241e5bbdfb59b122 /benchmark/path/parse-posix.js | |
parent | 955be8623d58566849cf6a59ff82e78cf14f239a (diff) | |
download | android-node-v8-038a1a489d6d0a4d5c075611943b3c7c08f0e22a.tar.gz android-node-v8-038a1a489d6d0a4d5c075611943b3c7c08f0e22a.tar.bz2 android-node-v8-038a1a489d6d0a4d5c075611943b3c7c08f0e22a.zip |
benchmark: refactor path benchmarks
So far the benchmarks created a highly specialized function which
would inline exactly to the input. This changes it to provide a
more realistic view to actual input by changing the input on each
iteration. That prevents the function to be to specific.
It also reduces the number of iterations the benchmarks are run to
reduce the overall runtime. A microbenchmark should already show a
significant difference with lower iterations, otherwise the
significance for real world applications is only limited.
PR-URL: https://github.com/nodejs/node/pull/26359
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'benchmark/path/parse-posix.js')
-rw-r--r-- | benchmark/path/parse-posix.js | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/benchmark/path/parse-posix.js b/benchmark/path/parse-posix.js index 00fdc6a3ad..7fb1d55099 100644 --- a/benchmark/path/parse-posix.js +++ b/benchmark/path/parse-posix.js @@ -12,16 +12,13 @@ const bench = common.createBenchmark(main, { 'foo/bar', '/foo/bar/baz/asdf/.quux', ], - n: [1e6] + n: [1e5] }); function main({ n, path }) { - for (var i = 0; i < n; i++) { - posix.parse(path); - } bench.start(); - for (i = 0; i < n; i++) { - posix.parse(path); + for (let i = 0; i < n; i++) { + posix.parse(i % 3 === 0 ? `${path}${i}` : path); } bench.end(n); } |