mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
cd0fcf20c3
PR-URL: https://github.com/nodejs/node/pull/47377 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Matthew Aitken <maitken033380023@gmail.com>
31 lines
687 B
JavaScript
31 lines
687 B
JavaScript
'use strict';
|
|
const common = require('../common.js');
|
|
const { fileURLToPath, pathToFileURL } = require('node:url');
|
|
const isWindows = process.platform === 'win32';
|
|
|
|
const bench = common.createBenchmark(main, {
|
|
input: isWindows ? [
|
|
'file:///c/',
|
|
] : [
|
|
'file:///dev/null',
|
|
'file:///dev/null?key=param&bool',
|
|
'file:///dev/null?key=param&bool#hash',
|
|
],
|
|
method: isWindows ? [
|
|
'fileURLToPath',
|
|
] : [
|
|
'fileURLToPath',
|
|
'pathToFileURL',
|
|
],
|
|
n: [5e6],
|
|
});
|
|
|
|
function main({ n, input, method }) {
|
|
method = method === 'fileURLOrPath' ? fileURLToPath : pathToFileURL;
|
|
bench.start();
|
|
for (let i = 0; i < n; i++) {
|
|
method(input);
|
|
}
|
|
bench.end(n);
|
|
}
|