From 518fced4796decd6bc099cc2f22f293e305b0a59 Mon Sep 17 00:00:00 2001 From: Yagiz Nizipli Date: Thu, 8 Dec 2022 09:37:57 -0500 Subject: [PATCH 1/2] benchmark: add variety of inputs to text-encoder --- benchmark/util/text-encoder.js | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/benchmark/util/text-encoder.js b/benchmark/util/text-encoder.js index ca3cb827779be3..50468e251ce1d7 100644 --- a/benchmark/util/text-encoder.js +++ b/benchmark/util/text-encoder.js @@ -2,17 +2,30 @@ const common = require('../common.js'); -const BASE = 'string\ud801'; - const bench = common.createBenchmark(main, { - len: [256, 1024, 1024 * 32], + len: [0, 256, 1024, 1024 * 32], n: [1e4], + type: ['one-byte-string', 'two-byte-string', 'ascii'], op: ['encode', 'encodeInto'] }); -function main({ n, op, len }) { +function main({ n, op, len, type }) { const encoder = new TextEncoder(); - const input = BASE.repeat(len); + let base = ''; + + switch (type) { + case 'ascii': + base = 'a'; + break; + case 'one-byte-string': + base = '\xff'; + break; + case 'two-byte-string': + base = 'ğ'; + break; + } + + const input = base.repeat(len); const subarray = new Uint8Array(len); bench.start(); From f244bd6f554fa40bd7e1f996b391ba1533d9185b Mon Sep 17 00:00:00 2001 From: Yagiz Nizipli Date: Thu, 8 Dec 2022 10:05:32 -0500 Subject: [PATCH 2/2] fixup! benchmark: add variety of inputs to text-encoder --- benchmark/util/text-encoder.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benchmark/util/text-encoder.js b/benchmark/util/text-encoder.js index 50468e251ce1d7..707f76df11dc89 100644 --- a/benchmark/util/text-encoder.js +++ b/benchmark/util/text-encoder.js @@ -3,7 +3,7 @@ const common = require('../common.js'); const bench = common.createBenchmark(main, { - len: [0, 256, 1024, 1024 * 32], + len: [16, 32, 256, 1024, 1024 * 32], n: [1e4], type: ['one-byte-string', 'two-byte-string', 'ascii'], op: ['encode', 'encodeInto']