summaryrefslogtreecommitdiff
path: root/benchmark
diff options
context:
space:
mode:
authorYagiz Nizipli <yagiz@nizipli.com>2022-12-15 18:11:07 -0500
committerNode.js GitHub Bot <github-bot@iojs.org>2022-12-22 20:22:28 +0000
commit2ef13b8fb638d9d7b815296dfbf6a631868ce001 (patch)
treef2b35018655fff0043e63058acacb030cda5c24c /benchmark
parentf4c200dc762dbedbb8d6b495a29708eb5be0c8dd (diff)
downloadnode-new-2ef13b8fb638d9d7b815296dfbf6a631868ce001.tar.gz
util: add fast path for text-decoder fatal flag
PR-URL: https://github.com/nodejs/node/pull/45803 Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Michael Dawson <midawson@redhat.com>
Diffstat (limited to 'benchmark')
-rw-r--r--benchmark/util/text-decoder.js11
1 files changed, 8 insertions, 3 deletions
diff --git a/benchmark/util/text-decoder.js b/benchmark/util/text-decoder.js
index 3d1ccc34bb..a669502860 100644
--- a/benchmark/util/text-decoder.js
+++ b/benchmark/util/text-decoder.js
@@ -5,13 +5,14 @@ const common = require('../common.js');
const bench = common.createBenchmark(main, {
encoding: ['utf-8', 'latin1', 'iso-8859-3'],
ignoreBOM: [0, 1],
+ fatal: [0, 1],
len: [256, 1024 * 16, 1024 * 512],
n: [1e2],
type: ['SharedArrayBuffer', 'ArrayBuffer', 'Buffer']
});
-function main({ encoding, len, n, ignoreBOM, type }) {
- const decoder = new TextDecoder(encoding, { ignoreBOM });
+function main({ encoding, len, n, ignoreBOM, type, fatal }) {
+ const decoder = new TextDecoder(encoding, { ignoreBOM, fatal });
let buf;
switch (type) {
@@ -31,7 +32,11 @@ function main({ encoding, len, n, ignoreBOM, type }) {
bench.start();
for (let i = 0; i < n; i++) {
- decoder.decode(buf);
+ try {
+ decoder.decode(buf);
+ } catch {
+ // eslint-disable no-empty
+ }
}
bench.end(n);
}