-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
util: improve textdecoder decode performance
PR-URL: #45294 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Minwoo Jung <[email protected]> Reviewed-By: Rich Trott <[email protected]>
- Loading branch information
1 parent
e0a8eff
commit 4730850
Showing
3 changed files
with
47 additions
and
14 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,19 @@ | ||
'use strict'; | ||
|
||
const common = require('../common.js'); | ||
|
||
const bench = common.createBenchmark(main, { | ||
encoding: ['utf-8', 'latin1', 'iso-8859-3'], | ||
ignoreBOM: [0, 1], | ||
len: [256, 1024 * 16, 1024 * 512], | ||
n: [1e6] | ||
}); | ||
|
||
function main({ encoding, len, n, ignoreBOM }) { | ||
const buf = Buffer.allocUnsafe(len); | ||
const decoder = new TextDecoder(encoding, { ignoreBOM }); | ||
|
||
bench.start(); | ||
decoder.decode(buf); | ||
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