summaryrefslogtreecommitdiff
path: root/benchmark/path/isAbsolute-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/isAbsolute-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/isAbsolute-posix.js')
-rw-r--r--benchmark/path/isAbsolute-posix.js32
1 files changed, 32 insertions, 0 deletions
diff --git a/benchmark/path/isAbsolute-posix.js b/benchmark/path/isAbsolute-posix.js
new file mode 100644
index 0000000000..4f8d89e654
--- /dev/null
+++ b/benchmark/path/isAbsolute-posix.js
@@ -0,0 +1,32 @@
+var common = require('../common.js');
+var path = require('path');
+var v8 = require('v8');
+
+var bench = common.createBenchmark(main, {
+ path: [
+ '',
+ '.',
+ '/foo/bar',
+ '/baz/..',
+ 'bar/baz'
+ ],
+ n: [1e6]
+});
+
+function main(conf) {
+ var n = +conf.n;
+ var p = path.posix;
+ var input = '' + conf.path;
+
+ // Force optimization before starting the benchmark
+ p.isAbsolute(input);
+ v8.setFlagsFromString('--allow_natives_syntax');
+ eval('%OptimizeFunctionOnNextCall(p.isAbsolute)');
+ p.isAbsolute(input);
+
+ bench.start();
+ for (var i = 0; i < n; i++) {
+ p.isAbsolute(input);
+ }
+ bench.end(n);
+}