From fbce12b7259cacea5d45ebf3503c8ac8a0200c73 Mon Sep 17 00:00:00 2001 From: Timo Stamm Date: Sat, 30 Oct 2021 22:53:13 +0200 Subject: [PATCH] Split utf8 benchmarks into decode / encode --- packages/benchmarks/bench-utf8.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/benchmarks/bench-utf8.ts b/packages/benchmarks/bench-utf8.ts index 0a8193a7..75debca6 100644 --- a/packages/benchmarks/bench-utf8.ts +++ b/packages/benchmarks/bench-utf8.ts @@ -59,6 +59,12 @@ for (let i = 3; i <= 14; i++) { for (let fix of fixtures) { console.log(`### ${fix.characters} characters`); - bench('@protobufjs/utf8 ', () => protobufJsDecode(protobufJsEncode(fix.text))); - bench('native ', () => nativeDecode(nativeEncode(fix.text))); + const bytes = nativeEncode(fix.text); + bench('decode @protobufjs/utf8 ', () => protobufJsDecode(bytes)); + bench('decode native ', () => nativeDecode(bytes)); +} +for (let fix of fixtures) { + console.log(`### ${fix.characters} characters`); + bench('encode @protobufjs/utf8 ', () => protobufJsEncode(fix.text)); + bench('encode native ', () => nativeEncode(fix.text)); }