summaryrefslogtreecommitdiff
path: root/benchmark/path/join-posix.js
diff options
context:
space:
mode:
authorBrian White <mscdex@mscdex.net>2016-02-05 22:23:29 -0500
committerJames M Snell <jasnell@gmail.com>2016-02-09 20:35:35 -0800
commite1348b0819d4d2aeb9a93c98dd31b9cacd951214 (patch)
treed39cf96374c5f9dcc9d5f6da25072f3768a1e80c /benchmark/path/join-posix.js
parent72d0f8821530bc77a369914c285a45991b2bf465 (diff)
downloadandroid-node-v8-e1348b0819d4d2aeb9a93c98dd31b9cacd951214.tar.gz
android-node-v8-e1348b0819d4d2aeb9a93c98dd31b9cacd951214.tar.bz2
android-node-v8-e1348b0819d4d2aeb9a93c98dd31b9cacd951214.zip
benchmark: split path benchmarks
This commit splits each path benchmark into separate posix and Windows benchmark files. This allows benchmarking (platform-)specific inputs against specific platforms (only). PR-URL: https://github.com/nodejs/node/pull/5123 Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'benchmark/path/join-posix.js')
-rw-r--r--benchmark/path/join-posix.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/benchmark/path/join-posix.js b/benchmark/path/join-posix.js
new file mode 100644
index 0000000000..4b8bb924a2
--- /dev/null
+++ b/benchmark/path/join-posix.js
@@ -0,0 +1,28 @@
+var common = require('../common.js');
+var path = require('path');
+var v8 = require('v8');
+
+var bench = common.createBenchmark(main, {
+ paths: [
+ ['/foo', 'bar', '', 'baz/asdf', 'quux', '..'].join('|')
+ ],
+ n: [1e6]
+});
+
+function main(conf) {
+ var n = +conf.n;
+ var p = path.posix;
+ var args = ('' + conf.paths).split('|');
+
+ // Force optimization before starting the benchmark
+ p.join.apply(null, args);
+ v8.setFlagsFromString('--allow_natives_syntax');
+ eval('%OptimizeFunctionOnNextCall(p.join)');
+ p.join.apply(null, args);
+
+ bench.start();
+ for (var i = 0; i < n; i++) {
+ p.join.apply(null, args);
+ }
+ bench.end(n);
+}