Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
benchmark: add toNamespacedPath bench
  • Loading branch information
RafaelGSS committed Mar 27, 2024
commit 85830da4fd814404ba490232430dc05d14868124
26 changes: 26 additions & 0 deletions benchmark/path/toNamespacedPath-posix.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
'use strict';
const common = require('../common.js');
const { posix } = require('path');
const assert = require('assert');

const bench = common.createBenchmark(main, {
path: [
'',
'.',
'/tmp/bar',
'/home/node/..',
__dirname + '/..',
'bar/baz',
],
n: [1e5],
});

function main({ n, path }) {
bench.start();
let a;
for (let i = 0; i < n; i++) {
a = posix.toNamespacedPath(path);
}
bench.end(n);
assert.ok(a + 'a')
}
28 changes: 28 additions & 0 deletions benchmark/path/toNamespacedPath-win32.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
'use strict';
const common = require('../common.js');
const { win32 } = require('path');
const assert = require('assert');

const bench = common.createBenchmark(main, {
path: [
'',
'c:/ignore',
'd:\\a/b\\c/d',
'\\e.exe',
'c:/blah\\blah',
'd:/games',
'c:../a',
__dirname + '/..',
],
n: [1e5],
});

function main({ n, path }) {
bench.start();
let a;
for (let i = 0; i < n; i++) {
a = win32.toNamespacedPath(path);
}
bench.end(n);
assert.ok(a + 'a')
}