mirror of https://github.com/lukechilds/node.git
Browse Source
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>process-exit-stdio-flushing
committed by
James M Snell
24 changed files with 592 additions and 152 deletions
@ -0,0 +1,43 @@ |
|||
var common = require('../common.js'); |
|||
var path = require('path'); |
|||
var v8 = require('v8'); |
|||
|
|||
var bench = common.createBenchmark(main, { |
|||
pathext: [ |
|||
'', |
|||
'/', |
|||
'/foo', |
|||
'/foo/.bar.baz', |
|||
['/foo/.bar.baz', '.baz'].join('|'), |
|||
'foo', |
|||
'foo/bar.', |
|||
['foo/bar.', '.'].join('|'), |
|||
'/foo/bar/baz/asdf/quux.html', |
|||
['/foo/bar/baz/asdf/quux.html', '.html'].join('|') |
|||
], |
|||
n: [1e6] |
|||
}); |
|||
|
|||
function main(conf) { |
|||
var n = +conf.n; |
|||
var p = path.posix; |
|||
var input = '' + conf.pathext; |
|||
var ext; |
|||
var extIdx = input.indexOf('|'); |
|||
if (extIdx !== -1) { |
|||
ext = input.slice(extIdx + 1); |
|||
input = input.slice(0, extIdx); |
|||
} |
|||
|
|||
// Force optimization before starting the benchmark
|
|||
p.basename(input, ext); |
|||
v8.setFlagsFromString('--allow_natives_syntax'); |
|||
eval('%OptimizeFunctionOnNextCall(p.basename)'); |
|||
p.basename(input, ext); |
|||
|
|||
bench.start(); |
|||
for (var i = 0; i < n; i++) { |
|||
p.basename(input, ext); |
|||
} |
|||
bench.end(n); |
|||
} |
@ -0,0 +1,43 @@ |
|||
var common = require('../common.js'); |
|||
var path = require('path'); |
|||
var v8 = require('v8'); |
|||
|
|||
var bench = common.createBenchmark(main, { |
|||
pathext: [ |
|||
'', |
|||
'C:\\', |
|||
'C:\\foo', |
|||
'D:\\foo\\.bar.baz', |
|||
['E:\\foo\\.bar.baz','.baz'].join('|'), |
|||
'foo', |
|||
'foo\\bar.', |
|||
['foo\\bar.', '.'].join('|'), |
|||
'\\foo\\bar\\baz\\asdf\\quux.html', |
|||
['\\foo\\bar\\baz\\asdf\\quux.html', '.html'].join('|') |
|||
], |
|||
n: [1e6] |
|||
}); |
|||
|
|||
function main(conf) { |
|||
var n = +conf.n; |
|||
var p = path.win32; |
|||
var input = '' + conf.pathext; |
|||
var ext; |
|||
var extIdx = input.indexOf('|'); |
|||
if (extIdx !== -1) { |
|||
ext = input.slice(extIdx + 1); |
|||
input = input.slice(0, extIdx); |
|||
} |
|||
|
|||
// Force optimization before starting the benchmark
|
|||
p.basename(input, ext); |
|||
v8.setFlagsFromString('--allow_natives_syntax'); |
|||
eval('%OptimizeFunctionOnNextCall(p.basename)'); |
|||
p.basename(input, ext); |
|||
|
|||
bench.start(); |
|||
for (var i = 0; i < n; i++) { |
|||
p.basename(input, ext); |
|||
} |
|||
bench.end(n); |
|||
} |
@ -1,26 +0,0 @@ |
|||
var common = require('../common.js'); |
|||
var path = require('path'); |
|||
var v8 = require('v8'); |
|||
|
|||
var bench = common.createBenchmark(main, { |
|||
type: ['win32', 'posix'], |
|||
n: [1e6], |
|||
}); |
|||
|
|||
function main(conf) { |
|||
var n = +conf.n; |
|||
var p = path[conf.type]; |
|||
|
|||
// Force optimization before starting the benchmark
|
|||
p.basename('/foo/bar/baz/asdf/quux.html'); |
|||
v8.setFlagsFromString('--allow_natives_syntax'); |
|||
eval('%OptimizeFunctionOnNextCall(p.basename)'); |
|||
p.basename('/foo/bar/baz/asdf/quux.html'); |
|||
|
|||
bench.start(); |
|||
for (var i = 0; i < n; i++) { |
|||
p.basename('/foo/bar/baz/asdf/quux.html'); |
|||
p.basename('/foo/bar/baz/asdf/quux.html', '.html'); |
|||
} |
|||
bench.end(n); |
|||
} |
@ -0,0 +1,34 @@ |
|||
var common = require('../common.js'); |
|||
var path = require('path'); |
|||
var v8 = require('v8'); |
|||
|
|||
var bench = common.createBenchmark(main, { |
|||
path: [ |
|||
'', |
|||
'\\', |
|||
'\\foo', |
|||
'C:\\foo\\bar', |
|||
'foo', |
|||
'foo\\bar', |
|||
'D:\\foo\\bar\\baz\\asdf\\quux' |
|||
], |
|||
n: [1e6] |
|||
}); |
|||
|
|||
function main(conf) { |
|||
var n = +conf.n; |
|||
var p = path.win32; |
|||
var input = '' + conf.path; |
|||
|
|||
// Force optimization before starting the benchmark
|
|||
p.dirname(input); |
|||
v8.setFlagsFromString('--allow_natives_syntax'); |
|||
eval('%OptimizeFunctionOnNextCall(p.dirname)'); |
|||
p.dirname(input); |
|||
|
|||
bench.start(); |
|||
for (var i = 0; i < n; i++) { |
|||
p.dirname(input); |
|||
} |
|||
bench.end(n); |
|||
} |
@ -0,0 +1,37 @@ |
|||
var common = require('../common.js'); |
|||
var path = require('path'); |
|||
var v8 = require('v8'); |
|||
|
|||
var bench = common.createBenchmark(main, { |
|||
path: [ |
|||
'', |
|||
'/', |
|||
'/foo', |
|||
'foo/.bar.baz', |
|||
'index.html', |
|||
'index', |
|||
'foo/bar/..baz.quux', |
|||
'foo/bar/...baz.quux', |
|||
'/foo/bar/baz/asdf/quux', |
|||
'/foo/bar/baz/asdf/quux.foobarbazasdfquux' |
|||
], |
|||
n: [1e6] |
|||
}); |
|||
|
|||
function main(conf) { |
|||
var n = +conf.n; |
|||
var p = path.posix; |
|||
var input = '' + conf.path; |
|||
|
|||
// Force optimization before starting the benchmark
|
|||
p.extname(input); |
|||
v8.setFlagsFromString('--allow_natives_syntax'); |
|||
eval('%OptimizeFunctionOnNextCall(p.extname)'); |
|||
p.extname(input); |
|||
|
|||
bench.start(); |
|||
for (var i = 0; i < n; i++) { |
|||
p.extname(input); |
|||
} |
|||
bench.end(n); |
|||
} |
@ -0,0 +1,37 @@ |
|||
var common = require('../common.js'); |
|||
var path = require('path'); |
|||
var v8 = require('v8'); |
|||
|
|||
var bench = common.createBenchmark(main, { |
|||
path: [ |
|||
'', |
|||
'\\', |
|||
'C:\\foo', |
|||
'foo\\.bar.baz', |
|||
'index.html', |
|||
'index', |
|||
'foo\\bar\\..baz.quux', |
|||
'foo\\bar\\...baz.quux', |
|||
'D:\\foo\\bar\\baz\\asdf\\quux', |
|||
'\\foo\\bar\\baz\\asdf\\quux.foobarbazasdfquux' |
|||
], |
|||
n: [1e6] |
|||
}); |
|||
|
|||
function main(conf) { |
|||
var n = +conf.n; |
|||
var p = path.win32; |
|||
var input = '' + conf.path; |
|||
|
|||
// Force optimization before starting the benchmark
|
|||
p.extname(input); |
|||
v8.setFlagsFromString('--allow_natives_syntax'); |
|||
eval('%OptimizeFunctionOnNextCall(p.extname)'); |
|||
p.extname(input); |
|||
|
|||
bench.start(); |
|||
for (var i = 0; i < n; i++) { |
|||
p.extname(input); |
|||
} |
|||
bench.end(n); |
|||
} |
@ -0,0 +1,35 @@ |
|||
var common = require('../common.js'); |
|||
var path = require('path'); |
|||
var v8 = require('v8'); |
|||
|
|||
var bench = common.createBenchmark(main, { |
|||
props: [ |
|||
['C:\\', 'C:\\path\\dir', 'index.html', '.html', 'index'].join('|') |
|||
], |
|||
n: [1e7] |
|||
}); |
|||
|
|||
function main(conf) { |
|||
var n = +conf.n; |
|||
var p = path.win32; |
|||
var props = ('' + conf.props).split('|'); |
|||
var obj = { |
|||
root: props[0] || '', |
|||
dir: props[1] || '', |
|||
base: props[2] || '', |
|||
ext: props[3] || '', |
|||
name: props[4] || '', |
|||
}; |
|||
|
|||
// Force optimization before starting the benchmark
|
|||
p.format(obj); |
|||
v8.setFlagsFromString('--allow_natives_syntax'); |
|||
eval('%OptimizeFunctionOnNextCall(p.format)'); |
|||
p.format(obj); |
|||
|
|||
bench.start(); |
|||
for (var i = 0; i < n; i++) { |
|||
p.format(obj); |
|||
} |
|||
bench.end(n); |
|||
} |
@ -0,0 +1,33 @@ |
|||
var common = require('../common.js'); |
|||
var path = require('path'); |
|||
var v8 = require('v8'); |
|||
|
|||
var bench = common.createBenchmark(main, { |
|||
path: [ |
|||
'', |
|||
'.', |
|||
'//server', |
|||
'C:\\baz\\..', |
|||
'C:baz\\..', |
|||
'bar\\baz' |
|||
], |
|||
n: [1e6] |
|||
}); |
|||
|
|||
function main(conf) { |
|||
var n = +conf.n; |
|||
var p = path.win32; |
|||
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); |
|||
} |
@ -1,34 +0,0 @@ |
|||
var common = require('../common.js'); |
|||
var path = require('path'); |
|||
var v8 = require('v8'); |
|||
|
|||
var bench = common.createBenchmark(main, { |
|||
type: ['win32', 'posix'], |
|||
n: [1e6], |
|||
}); |
|||
|
|||
function main(conf) { |
|||
var n = +conf.n; |
|||
var p = path[conf.type]; |
|||
var tests = conf.type === 'win32' |
|||
? ['//server', 'C:\\baz\\..', 'bar\\baz', '.'] |
|||
: ['/foo/bar', '/baz/..', 'bar/baz', '.']; |
|||
|
|||
// Force optimization before starting the benchmark
|
|||
p.isAbsolute(tests[0]); |
|||
v8.setFlagsFromString('--allow_natives_syntax'); |
|||
eval('%OptimizeFunctionOnNextCall(p.isAbsolute)'); |
|||
p.isAbsolute(tests[0]); |
|||
|
|||
bench.start(); |
|||
for (var i = 0; i < n; i++) { |
|||
runTests(p, tests); |
|||
} |
|||
bench.end(n); |
|||
} |
|||
|
|||
function runTests(p, tests) { |
|||
for (var i = 0; i < tests.length; i++) { |
|||
p.isAbsolute(tests[i]); |
|||
} |
|||
} |
@ -0,0 +1,28 @@ |
|||
var common = require('../common.js'); |
|||
var path = require('path'); |
|||
var v8 = require('v8'); |
|||
|
|||
var bench = common.createBenchmark(main, { |
|||
paths: [ |
|||
['C:\\foo', 'bar', '', 'baz\\asdf', 'quux', '..'].join('|') |
|||
], |
|||
n: [1e6] |
|||
}); |
|||
|
|||
function main(conf) { |
|||
var n = +conf.n; |
|||
var p = path.win32; |
|||
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); |
|||
} |
@ -0,0 +1,31 @@ |
|||
var common = require('../common.js'); |
|||
var path = require('path'); |
|||
var v8 = require('v8'); |
|||
|
|||
var bench = common.createBenchmark(main, { |
|||
path: [ |
|||
'foo\\bar', |
|||
'C:\\foo', |
|||
'\\\\foo\\bar', |
|||
'\\\\?\\foo' |
|||
], |
|||
n: [1e6] |
|||
}); |
|||
|
|||
function main(conf) { |
|||
var n = +conf.n; |
|||
var p = path.win32; |
|||
var input = '' + conf.path; |
|||
|
|||
// Force optimization before starting the benchmark
|
|||
p._makeLong(input); |
|||
v8.setFlagsFromString('--allow_natives_syntax'); |
|||
eval('%OptimizeFunctionOnNextCall(p._makeLong)'); |
|||
p._makeLong(input); |
|||
|
|||
bench.start(); |
|||
for (var i = 0; i < n; i++) { |
|||
p._makeLong(input); |
|||
} |
|||
bench.end(n); |
|||
} |
@ -0,0 +1,33 @@ |
|||
var common = require('../common.js'); |
|||
var path = require('path'); |
|||
var v8 = require('v8'); |
|||
|
|||
var bench = common.createBenchmark(main, { |
|||
path: [ |
|||
'', |
|||
'.', |
|||
'C:\\..\\', |
|||
'C:\\foo', |
|||
'C:\\foo\\bar', |
|||
'C:\\foo\\bar\\\\baz\\asdf\\quux\\..' |
|||
], |
|||
n: [1e6] |
|||
}); |
|||
|
|||
function main(conf) { |
|||
var n = +conf.n; |
|||
var p = path.win32; |
|||
var input = '' + conf.path; |
|||
|
|||
// Force optimization before starting the benchmark
|
|||
p.normalize(input); |
|||
v8.setFlagsFromString('--allow_natives_syntax'); |
|||
eval('%OptimizeFunctionOnNextCall(p.normalize)'); |
|||
p.normalize(input); |
|||
|
|||
bench.start(); |
|||
for (var i = 0; i < n; i++) { |
|||
p.normalize(input); |
|||
} |
|||
bench.end(n); |
|||
} |
@ -0,0 +1,35 @@ |
|||
var common = require('../common.js'); |
|||
var path = require('path'); |
|||
var v8 = require('v8'); |
|||
|
|||
var bench = common.createBenchmark(main, { |
|||
path: [ |
|||
'', |
|||
'C:\\', |
|||
'C:\\foo', |
|||
'\\foo', |
|||
'E:\\foo\\bar.baz', |
|||
'foo\\.bar.baz', |
|||
'foo\\bar', |
|||
'\\foo\\bar\\baz\\asdf\\.quux' |
|||
], |
|||
n: [1e6] |
|||
}); |
|||
|
|||
function main(conf) { |
|||
var n = +conf.n; |
|||
var p = path.win32; |
|||
var input = '' + conf.path; |
|||
|
|||
// Force optimization before starting the benchmark
|
|||
p.parse(input); |
|||
v8.setFlagsFromString('--allow_natives_syntax'); |
|||
eval('%OptimizeFunctionOnNextCall(p.parse)'); |
|||
p.parse(input); |
|||
|
|||
bench.start(); |
|||
for (var i = 0; i < n; i++) { |
|||
p.parse(input); |
|||
} |
|||
bench.end(n); |
|||
} |
@ -0,0 +1,40 @@ |
|||
var common = require('../common.js'); |
|||
var path = require('path'); |
|||
var v8 = require('v8'); |
|||
|
|||
var bench = common.createBenchmark(main, { |
|||
paths: [ |
|||
['/data/orandea/test/aaa', '/data/orandea/impl/bbb'].join('|'), |
|||
['/', '/var'].join('|'), |
|||
['/', '/'].join('|'), |
|||
['/var', '/bin'].join('|'), |
|||
['/foo/bar/baz/quux', '/'].join('|'), |
|||
['/foo/bar/baz/quux', '/foo/bar/baz/quux'].join('|'), |
|||
['/foo/bar/baz/quux', '/var/log'].join('|') |
|||
], |
|||
n: [1e6] |
|||
}); |
|||
|
|||
function main(conf) { |
|||
var n = +conf.n; |
|||
var p = path.posix; |
|||
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); |
|||
} |
@ -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); |
|||
} |
@ -1,33 +0,0 @@ |
|||
var common = require('../common.js'); |
|||
var path = require('path'); |
|||
var v8 = require('v8'); |
|||
|
|||
var bench = common.createBenchmark(main, { |
|||
type: ['win32', 'posix'], |
|||
n: [1e5], |
|||
}); |
|||
|
|||
function main(conf) { |
|||
var n = +conf.n; |
|||
var runTest = conf.type === 'win32' ? runWin32Test : runPosixTest; |
|||
|
|||
// Force optimization before starting the benchmark
|
|||
runTest(); |
|||
v8.setFlagsFromString('--allow_natives_syntax'); |
|||
eval('%OptimizeFunctionOnNextCall(path[conf.type].relative)'); |
|||
runTest(); |
|||
|
|||
bench.start(); |
|||
for (var i = 0; i < n; i++) { |
|||
runTest(); |
|||
} |
|||
bench.end(n); |
|||
} |
|||
|
|||
function runWin32Test() { |
|||
path.win32.relative('C:\\orandea\\test\\aaa', 'C:\\orandea\\impl\\bbb'); |
|||
} |
|||
|
|||
function runPosixTest() { |
|||
path.posix.relative('/data/orandea/test/aaa', '/data/orandea/impl/bbb'); |
|||
} |
@ -0,0 +1,31 @@ |
|||
var common = require('../common.js'); |
|||
var path = require('path'); |
|||
var v8 = require('v8'); |
|||
|
|||
var bench = common.createBenchmark(main, { |
|||
paths: [ |
|||
'', |
|||
['', ''].join('|'), |
|||
['c:/ignore', 'd:\\a/b\\c/d', '\\e.exe'].join('|'), |
|||
['c:/blah\\blah', 'd:/games', 'c:../a'].join('|') |
|||
], |
|||
n: [1e6] |
|||
}); |
|||
|
|||
function main(conf) { |
|||
var n = +conf.n; |
|||
var p = path.win32; |
|||
var args = ('' + conf.paths).split('|'); |
|||
|
|||
// Force optimization before starting the benchmark
|
|||
p.resolve.apply(null, args); |
|||
v8.setFlagsFromString('--allow_natives_syntax'); |
|||
eval('%OptimizeFunctionOnNextCall(p.resolve)'); |
|||
p.resolve.apply(null, args); |
|||
|
|||
bench.start(); |
|||
for (var i = 0; i < n; i++) { |
|||
p.resolve.apply(null, args); |
|||
} |
|||
bench.end(n); |
|||
} |
Loading…
Reference in new issue