-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
errors: improve formatList in errors.js
PR-URL: #49642 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: LiviaMedeiros <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
- Loading branch information
Showing
3 changed files
with
53 additions
and
3 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,44 @@ | ||
'use strict'; | ||
|
||
const common = require('../common.js'); | ||
|
||
const bench = common.createBenchmark(main, { | ||
n: [1e7], | ||
input: [ | ||
'', | ||
'a', | ||
'a,b', | ||
'a,b,c', | ||
'a,b,c,d', | ||
], | ||
type: [ | ||
'undefined', | ||
'and', | ||
'or', | ||
], | ||
}, { | ||
flags: ['--expose-internals'], | ||
}); | ||
|
||
function main({ n, input, type }) { | ||
const { | ||
formatList, | ||
} = require('internal/errors'); | ||
|
||
const list = input.split(','); | ||
|
||
if (type === 'undefined') { | ||
bench.start(); | ||
for (let i = 0; i < n; ++i) { | ||
formatList(list); | ||
} | ||
bench.end(n); | ||
return; | ||
} | ||
|
||
bench.start(); | ||
for (let i = 0; i < n; ++i) { | ||
formatList(list, type); | ||
} | ||
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