forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
url: refactor to use more primordials
PR-URL: nodejs#45966 Reviewed-By: Zeyu "Alex" Yang <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
- Loading branch information
Showing
4 changed files
with
59 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
'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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters