From 3db02fe28bf34c828662aa4e3c0e3aff58ab4038 Mon Sep 17 00:00:00 2001 From: Anton Golub Date: Fri, 10 Jan 2025 15:27:08 +0300 Subject: [PATCH] test(bench): add buf-join aliternatives --- src/core.ts | 5 ++++- test/bench/buf-join.mjs | 12 ++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/core.ts b/src/core.ts index c8ec8d39ec..4b228fc128 100644 --- a/src/core.ts +++ b/src/core.ts @@ -520,7 +520,10 @@ export class ProcessPromise extends Promise { return this } - timeout(d: Duration, signal = this._timeoutSignal || $.timeoutSignal): ProcessPromise { + timeout( + d: Duration, + signal = this._timeoutSignal || $.timeoutSignal + ): ProcessPromise { if (this._resolved) return this this._timeout = parseDuration(d) diff --git a/test/bench/buf-join.mjs b/test/bench/buf-join.mjs index 159786a611..58097069b1 100644 --- a/test/bench/buf-join.mjs +++ b/test/bench/buf-join.mjs @@ -27,12 +27,24 @@ cronometro({ buf_arr_reduce_decode() { BUF_ARR.reduce((acc, buf) => acc + decoder.decode(buf), '') }, + buf_arr_reduce_to_string() { + BUF_ARR.reduce((acc, buf) => acc + buf.toString('utf8'), '') + }, buf_arr_for_decode() { let res = '' for (const buf of BUF_ARR) { res += decoder.decode(buf) } }, + buf_arr_while_decode() { + let res = '' + let i = 0 + const bl = BUF_ARR.length + while (i < bl) { + res += decoder.decode(BUF_ARR[i]) + i++ + } + }, buf_arr_join() { BUF_ARR.join('') },