diff options
author | Brian White <mscdex@mscdex.net> | 2016-02-05 22:23:29 -0500 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2016-02-09 20:35:35 -0800 |
commit | e1348b0819d4d2aeb9a93c98dd31b9cacd951214 (patch) | |
tree | d39cf96374c5f9dcc9d5f6da25072f3768a1e80c /benchmark/path/relative-win32.js | |
parent | 72d0f8821530bc77a369914c285a45991b2bf465 (diff) | |
download | android-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/relative-win32.js')
-rw-r--r-- | benchmark/path/relative-win32.js | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/benchmark/path/relative-win32.js b/benchmark/path/relative-win32.js new file mode 100644 index 0000000000..f3eab74d26 --- /dev/null +++ b/benchmark/path/relative-win32.js @@ -0,0 +1,38 @@ +var common = require('../common.js'); +var path = require('path'); +var v8 = require('v8'); + +var bench = common.createBenchmark(main, { + paths: [ + ['C:\\orandea\\test\\aaa', 'C:\\orandea\\impl\\bbb'].join('|'), + ['C:\\', 'D:\\'].join('|'), + ['C:\\foo\\bar\\baz', 'C:\\foo\\bar\\baz'].join('|'), + ['C:\\foo\\BAR\\BAZ', 'C:\\foo\\bar\\baz'].join('|'), + ['C:\\foo\\bar\\baz\\quux', 'C:\\'].join('|') + ], + n: [1e6] +}); + +function main(conf) { + var n = +conf.n; + var p = path.win32; + var from = '' + conf.paths; + var to = ''; + var delimIdx = from.indexOf('|'); + if (delimIdx > -1) { + to = from.slice(delimIdx + 1); + from = from.slice(0, delimIdx); + } + + // Force optimization before starting the benchmark + p.relative(from, to); + v8.setFlagsFromString('--allow_natives_syntax'); + eval('%OptimizeFunctionOnNextCall(p.relative)'); + p.relative(from, to); + + bench.start(); + for (var i = 0; i < n; i++) { + p.relative(from, to); + } + bench.end(n); +} |