提交 0a900949 编写于 作者: L Luca Casonato 提交者: Ry Dahl

Added textencoder benchmark (#3589)

上级 9f6bab60
const mixed = "@Ā๐😀";
function generateRandom(bytes) {
let result = "";
let i = 0;
while (i < bytes) {
const toAdd = Math.floor(Math.random() * Math.min(4, bytes - i));
switch (toAdd) {
case 0:
result += mixed[0];
i++;
break;
case 1:
result += mixed[1];
i++;
break;
case 2:
result += mixed[2];
i++;
break;
case 3:
result += mixed[3];
result += mixed[4];
i += 2;
break;
}
}
return result;
}
const randomData = generateRandom(1024);
const encoder = new TextEncoder();
for (let i = 0; i < 10_000; i++) encoder.encode(randomData);
......@@ -28,6 +28,7 @@ exec_time_benchmarks = [
("workers_startup", ["tests/workers_startup_bench.ts"]),
("workers_round_robin", ["tests/workers_round_robin_bench.ts"]),
("text_decoder", ["cli/tests/text_decoder_perf.js"]),
("text_encoder", ["cli/tests/text_encoder_perf.js"]),
]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册