Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'benchmark/path/format.js')
-rw-r--r--benchmark/path/format.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/benchmark/path/format.js b/benchmark/path/format.js
new file mode 100644
index 00000000000..02fb691fe7f
--- /dev/null
+++ b/benchmark/path/format.js
@@ -0,0 +1,31 @@
+var common = require('../common.js');
+var path = require('path');
+
+var bench = common.createBenchmark(main, {
+ type: ['win32', 'posix'],
+ n: [1e7],
+});
+
+function main(conf) {
+ var n = +conf.n;
+ var p = path[conf.type];
+ var test = conf.type === 'win32' ? {
+ root: 'C:\\',
+ dir: 'C:\\path\\dir',
+ base: 'index.html',
+ ext: '.html',
+ name: 'index'
+ } : {
+ root : '/',
+ dir : '/home/user/dir',
+ base : 'index.html',
+ ext : '.html',
+ name : 'index'
+ };
+
+ bench.start();
+ for (var i = 0; i < n; i++) {
+ p.format(test);
+ }
+ bench.end(n);
+}