Skip to content

util: improve performance of normalizeEncoding #50721

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
Nov 16, 2023

Conversation

kylo5aby
Copy link
Contributor

@kylo5aby kylo5aby commented Nov 14, 2023

Improve performance of normalizeEncoding by using primordial.

Benchmark Results:

util/normalize-encoding.js n=100000 input=''                  ***      6.93 %       ±3.29%  ±4.38%  ±5.70%
util/normalize-encoding.js n=100000 input='base64'            ***      5.35 %       ±2.57%  ±3.42%  ±4.46%
util/normalize-encoding.js n=100000 input='BASE64'              *     -2.33 %       ±2.29%  ±3.05%  ±3.98%
util/normalize-encoding.js n=100000 input='binary'                    -1.38 %       ±2.95%  ±3.92%  ±5.10%
util/normalize-encoding.js n=100000 input='BINARY'                    -1.48 %       ±1.56%  ±2.07%  ±2.70%
util/normalize-encoding.js n=100000 input='foo'                        2.08 %       ±2.23%  ±2.97%  ±3.87%
util/normalize-encoding.js n=100000 input='group_common'      ***     11.06 %       ±2.04%  ±2.71%  ±3.53%
util/normalize-encoding.js n=100000 input='group_misc'        ***     16.66 %       ±2.19%  ±2.91%  ±3.80%
util/normalize-encoding.js n=100000 input='group_uncommon'    ***      6.37 %       ±2.67%  ±3.55%  ±4.63%
util/normalize-encoding.js n=100000 input='group_upper'       ***     20.02 %       ±1.97%  ±2.62%  ±3.42%
util/normalize-encoding.js n=100000 input='hex'               ***      5.49 %       ±2.85%  ±3.79%  ±4.94%
util/normalize-encoding.js n=100000 input='HEX'                 *      3.19 %       ±2.66%  ±3.54%  ±4.61%
util/normalize-encoding.js n=100000 input='latin1'                    -0.62 %       ±2.70%  ±3.60%  ±4.69%
util/normalize-encoding.js n=100000 input='ucs2'              ***      7.78 %       ±2.40%  ±3.20%  ±4.16%
util/normalize-encoding.js n=100000 input='UCS2'               **      2.99 %       ±1.99%  ±2.66%  ±3.48%
util/normalize-encoding.js n=100000 input='undefined'                  2.42 %       ±4.90%  ±6.51%  ±8.48%
util/normalize-encoding.js n=100000 input='utf-8'                     -1.34 %       ±4.21%  ±5.60%  ±7.29%
util/normalize-encoding.js n=100000 input='UTF-8'                      0.85 %       ±2.50%  ±3.32%  ±4.33%
util/normalize-encoding.js n=100000 input='utf16le'            **      4.10 %       ±3.06%  ±4.06%  ±5.29%
util/normalize-encoding.js n=100000 input='UTF16LE'                   -0.75 %       ±2.36%  ±3.14%  ±4.09%
util/normalize-encoding.js n=100000 input='utf8'                      -1.64 %       ±3.63%  ±4.83%  ±6.29%
util/normalize-encoding.js n=100000 input='Utf8'              ***      4.40 %       ±1.65%  ±2.20%  ±2.86%
util/normalize-encoding.js n=100000 input='UTF8'              ***      7.20 %       ±2.95%  ±3.92%  ±5.10%

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. util Issues and PRs related to the built-in util module. labels Nov 14, 2023
@marco-ippolito marco-ippolito added the request-ci Add this label to start a Jenkins CI on a PR. label Nov 14, 2023
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Nov 14, 2023
@nodejs-github-bot
Copy link
Collaborator

Copy link
Member

@H4ad H4ad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are not performing the same operation, if enc is not a string, it will throw an error.

String.prototype.toLowerCase.call(undefined, [])

So we should stringify when enc is not string and then perform toLowerCase.

What you can do is add a slow path of stringify only when enc is not a string, so maybe we can keep the fast-path with these new improvements.


Also, let's wait for the Benchmark CI results:

https://ci.nodejs.org/view/Node.js%20benchmark/job/benchmark-node-micro-benchmarks/1471/

@kylo5aby
Copy link
Contributor Author

kylo5aby commented Nov 16, 2023

They are not performing the same operation, if enc is not a string, it will throw an error.

String.prototype.toLowerCase.call(undefined, [])

So we should stringify when enc is not string and then perform toLowerCase.

What you can do is add a slow path of stringify only when enc is not a string, so maybe we can keep the fast-path with these new improvements.

Also, let's wait for the Benchmark CI results:

https://ci.nodejs.org/view/Node.js%20benchmark/job/benchmark-node-micro-benchmarks/1471/

Thanks for your advise. But enc can't be undefined or null in the switch(enc.length) ...case... block. so in this case, if enc has a type other than string, it does the same thing as String.prototype.toLowerCase.call(${env}, []) implicitly.

@H4ad
Copy link
Member

H4ad commented Nov 16, 2023

@zhenweijin You are right, my example was wrong.

In this case, I think this change is safe to introduce.


Benchmark Result:

util/format.js type='many-%' n=100000                                                                                    2.66 %       ±8.52% ±11.34% ±14.77%
util/format.js type='no-replace-2' n=100000                                                                              2.62 %       ±6.03%  ±8.03% ±10.47%
util/format.js type='no-replace' n=100000                                                                               -0.34 %       ±6.93%  ±9.22% ±12.00%
util/format.js type='number' n=100000                                                                                    1.36 %       ±4.58%  ±6.13%  ±8.04%
util/format.js type='object-%s' n=100000                                                                                 0.14 %       ±6.63%  ±8.83% ±11.50%
util/format.js type='object-to-string' n=100000                                                                          3.12 %       ±8.93% ±11.88% ±15.46%
util/format.js type='only-objects' n=100000                                                                              4.48 %       ±5.84%  ±7.77% ±10.11%
util/format.js type='replace-object' n=100000                                                                            2.35 %      ±10.02% ±13.33% ±17.36%
util/format.js type='string-2' n=100000                                                                                 -3.77 %       ±5.92%  ±7.89% ±10.28%
util/format.js type='string' n=100000                                                                                    0.45 %       ±4.28%  ±5.70%  ±7.42%
util/format.js type='unknown' n=100000                                                                                   2.88 %       ±5.10%  ±6.78%  ±8.83%
util/inspect-array.js type='denseArray_showHidden' len=100 n=500                                                        -1.61 %       ±5.72%  ±7.62%  ±9.93%
util/inspect-array.js type='denseArray_showHidden' len=100000 n=500                                                     -5.41 %       ±7.73% ±10.29% ±13.41%
util/inspect-array.js type='denseArray' len=100 n=500                                                                   -1.63 %       ±5.25%  ±7.00%  ±9.12%
util/inspect-array.js type='denseArray' len=100000 n=500                                                                -2.92 %       ±5.09%  ±6.78%  ±8.85%
util/inspect-array.js type='mixedArray' len=100 n=500                                                                    0.01 %       ±6.01%  ±8.00% ±10.41%
util/inspect-array.js type='mixedArray' len=100000 n=500                                                                -3.08 %       ±7.29%  ±9.70% ±12.62%
util/inspect-array.js type='sparseArray' len=100 n=500                                                            *      8.48 %       ±7.28%  ±9.73% ±12.72%
util/inspect-array.js type='sparseArray' len=100000 n=500                                                                2.83 %       ±7.31%  ±9.73% ±12.66%
util/inspect-proxy.js isProxy=0 showProxy=0 n=100000                                                                     5.12 %       ±5.18%  ±6.90%  ±8.98%
util/inspect-proxy.js isProxy=0 showProxy=1 n=100000                                                                     0.83 %       ±5.22%  ±6.94%  ±9.04%
util/inspect-proxy.js isProxy=1 showProxy=0 n=100000                                                                     1.30 %       ±5.42%  ±7.21%  ±9.39%
util/inspect-proxy.js isProxy=1 showProxy=1 n=100000                                                                     0.76 %       ±4.67%  ±6.22%  ±8.09%
util/inspect.js option='colors' method='Array' n=20000                                                                  -0.17 %       ±2.33%  ±3.11%  ±4.04%
util/inspect.js option='colors' method='Date' n=20000                                                                    6.13 %       ±9.84% ±13.10% ±17.08%
util/inspect.js option='colors' method='Error' n=20000                                                                   2.99 %       ±9.01% ±11.99% ±15.61%
util/inspect.js option='colors' method='Number' n=20000                                                                 -0.74 %       ±5.61%  ±7.47%  ±9.72%
util/inspect.js option='colors' method='Object_deep_ln' n=20000                                                         -1.91 %       ±5.98%  ±7.95% ±10.35%
util/inspect.js option='colors' method='Object_empty' n=20000                                                           -2.51 %       ±4.81%  ±6.40%  ±8.34%
util/inspect.js option='colors' method='Object' n=20000                                                           *     -7.98 %       ±7.54% ±10.05% ±13.11%
util/inspect.js option='colors' method='Set' n=20000                                                                     2.28 %       ±8.60% ±11.45% ±14.91%
util/inspect.js option='colors' method='String_boxed' n=20000                                                            3.48 %       ±8.82% ±11.74% ±15.28%
util/inspect.js option='colors' method='String_complex' n=20000                                                          0.46 %       ±6.12%  ±8.14% ±10.60%
util/inspect.js option='colors' method='String' n=20000                                                                  4.75 %       ±5.53%  ±7.36%  ±9.58%
util/inspect.js option='colors' method='TypedArray_extra' n=20000                                                        0.52 %       ±2.48%  ±3.30%  ±4.29%
util/inspect.js option='colors' method='TypedArray' n=20000                                                              0.48 %       ±3.17%  ±4.21%  ±5.49%
util/inspect.js option='none' method='Array' n=20000                                                                     1.62 %       ±4.13%  ±5.50%  ±7.16%
util/inspect.js option='none' method='Date' n=20000                                                                      0.48 %       ±9.33% ±12.42% ±16.16%
util/inspect.js option='none' method='Error' n=20000                                                                     3.01 %       ±7.22%  ±9.62% ±12.54%
util/inspect.js option='none' method='Number' n=20000                                                                   -0.01 %       ±4.12%  ±5.48%  ±7.13%
util/inspect.js option='none' method='Object_deep_ln' n=20000                                                    **    -11.26 %       ±8.05% ±10.72% ±13.95%
util/inspect.js option='none' method='Object_empty' n=20000                                                              2.54 %       ±5.41%  ±7.21%  ±9.38%
util/inspect.js option='none' method='Object' n=20000                                                                   -4.24 %       ±8.93% ±11.88% ±15.46%
util/inspect.js option='none' method='Set' n=20000                                                                       3.41 %       ±7.22%  ±9.61% ±12.51%
util/inspect.js option='none' method='String_boxed' n=20000                                                              4.44 %       ±8.90% ±11.85% ±15.42%
util/inspect.js option='none' method='String_complex' n=20000                                                           -1.28 %       ±5.51%  ±7.34%  ±9.55%
util/inspect.js option='none' method='String' n=20000                                                                    2.16 %       ±5.70%  ±7.59%  ±9.88%
util/inspect.js option='none' method='TypedArray_extra' n=20000                                                         -0.40 %       ±5.19%  ±6.90%  ±8.98%
util/inspect.js option='none' method='TypedArray' n=20000                                                                1.83 %       ±7.47%  ±9.95% ±12.95%
util/inspect.js option='showHidden' method='Array' n=20000                                                               1.39 %       ±4.77%  ±6.35%  ±8.27%
util/inspect.js option='showHidden' method='Date' n=20000                                                                5.79 %       ±9.28% ±12.36% ±16.09%
util/inspect.js option='showHidden' method='Error' n=20000                                                               1.95 %       ±8.86% ±11.78% ±15.34%
util/inspect.js option='showHidden' method='Number' n=20000                                                              0.21 %       ±3.89%  ±5.18%  ±6.75%
util/inspect.js option='showHidden' method='Object_deep_ln' n=20000                                                     -3.20 %       ±8.74% ±11.63% ±15.14%
util/inspect.js option='showHidden' method='Object_empty' n=20000                                                       -0.04 %       ±5.71%  ±7.60%  ±9.90%
util/inspect.js option='showHidden' method='Object' n=20000                                                             -3.17 %       ±7.69% ±10.24% ±13.33%
util/inspect.js option='showHidden' method='Set' n=20000                                                                 5.04 %       ±7.52% ±10.02% ±13.07%
util/inspect.js option='showHidden' method='String_boxed' n=20000                                                        7.93 %       ±9.59% ±12.76% ±16.62%
util/inspect.js option='showHidden' method='String_complex' n=20000                                                     -3.04 %       ±5.36%  ±7.14%  ±9.29%
util/inspect.js option='showHidden' method='String' n=20000                                                              1.95 %       ±5.48%  ±7.29%  ±9.48%
util/inspect.js option='showHidden' method='TypedArray_extra' n=20000                                             *      6.96 %       ±6.50%  ±8.65% ±11.25%
util/inspect.js option='showHidden' method='TypedArray' n=20000                                                          2.31 %       ±6.77%  ±9.01% ±11.73%
util/normalize-encoding.js n=100000 input=''                                                                    ***      6.93 %       ±3.29%  ±4.38%  ±5.70%
util/normalize-encoding.js n=100000 input='base64'                                                              ***      5.35 %       ±2.57%  ±3.42%  ±4.46%
util/normalize-encoding.js n=100000 input='BASE64'                                                                *     -2.33 %       ±2.29%  ±3.05%  ±3.98%
util/normalize-encoding.js n=100000 input='binary'                                                                      -1.38 %       ±2.95%  ±3.92%  ±5.10%
util/normalize-encoding.js n=100000 input='BINARY'                                                                      -1.48 %       ±1.56%  ±2.07%  ±2.70%
util/normalize-encoding.js n=100000 input='foo'                                                                          2.08 %       ±2.23%  ±2.97%  ±3.87%
util/normalize-encoding.js n=100000 input='group_common'                                                        ***     11.06 %       ±2.04%  ±2.71%  ±3.53%
util/normalize-encoding.js n=100000 input='group_misc'                                                          ***     16.66 %       ±2.19%  ±2.91%  ±3.80%
util/normalize-encoding.js n=100000 input='group_uncommon'                                                      ***      6.37 %       ±2.67%  ±3.55%  ±4.63%
util/normalize-encoding.js n=100000 input='group_upper'                                                         ***     20.02 %       ±1.97%  ±2.62%  ±3.42%
util/normalize-encoding.js n=100000 input='hex'                                                                 ***      5.49 %       ±2.85%  ±3.79%  ±4.94%
util/normalize-encoding.js n=100000 input='HEX'                                                                   *      3.19 %       ±2.66%  ±3.54%  ±4.61%
util/normalize-encoding.js n=100000 input='latin1'                                                                      -0.62 %       ±2.70%  ±3.60%  ±4.69%
util/normalize-encoding.js n=100000 input='ucs2'                                                                ***      7.78 %       ±2.40%  ±3.20%  ±4.16%
util/normalize-encoding.js n=100000 input='UCS2'                                                                 **      2.99 %       ±1.99%  ±2.66%  ±3.48%
util/normalize-encoding.js n=100000 input='undefined'                                                                    2.42 %       ±4.90%  ±6.51%  ±8.48%
util/normalize-encoding.js n=100000 input='utf-8'                                                                       -1.34 %       ±4.21%  ±5.60%  ±7.29%
util/normalize-encoding.js n=100000 input='UTF-8'                                                                        0.85 %       ±2.50%  ±3.32%  ±4.33%
util/normalize-encoding.js n=100000 input='utf16le'                                                              **      4.10 %       ±3.06%  ±4.06%  ±5.29%
util/normalize-encoding.js n=100000 input='UTF16LE'                                                                     -0.75 %       ±2.36%  ±3.14%  ±4.09%
util/normalize-encoding.js n=100000 input='utf8'                                                                        -1.64 %       ±3.63%  ±4.83%  ±6.29%
util/normalize-encoding.js n=100000 input='Utf8'                                                                ***      4.40 %       ±1.65%  ±2.20%  ±2.86%
util/normalize-encoding.js n=100000 input='UTF8'                                                                ***      7.20 %       ±2.95%  ±3.92%  ±5.10%
util/priority-queue.js n=100000                                                                                         -0.09 %       ±0.85%  ±1.13%  ±1.47%
util/splice-one.js size=10 pos='end' n=100000                                                                           -1.94 %       ±3.80%  ±5.05%  ±6.58%
util/splice-one.js size=10 pos='middle' n=100000                                                                        -0.92 %       ±2.80%  ±3.73%  ±4.86%
util/splice-one.js size=10 pos='start' n=100000                                                                          1.14 %       ±2.12%  ±2.83%  ±3.68%
util/splice-one.js size=100 pos='end' n=100000                                                                          -3.11 %       ±3.96%  ±5.28%  ±6.87%
util/splice-one.js size=100 pos='middle' n=100000                                                                        1.22 %       ±2.38%  ±3.19%  ±4.18%
util/splice-one.js size=100 pos='start' n=100000                                                                         0.15 %       ±1.00%  ±1.33%  ±1.74%
util/splice-one.js size=500 pos='end' n=100000                                                                   **     -6.60 %       ±4.04%  ±5.39%  ±7.02%
util/splice-one.js size=500 pos='middle' n=100000                                                                       -1.29 %       ±5.28%  ±7.03%  ±9.16%
util/splice-one.js size=500 pos='start' n=100000                                                                         1.51 %       ±1.88%  ±2.53%  ±3.36%
util/text-decoder.js type='ArrayBuffer' n=100 len=16384 fatal=0 ignoreBOM=0 encoding='iso-8859-3'                        2.88 %       ±4.20%  ±5.59%  ±7.27%
util/text-decoder.js type='ArrayBuffer' n=100 len=16384 fatal=0 ignoreBOM=0 encoding='latin1'                            2.59 %       ±4.88%  ±6.50%  ±8.48%
util/text-decoder.js type='ArrayBuffer' n=100 len=16384 fatal=0 ignoreBOM=0 encoding='utf-8'                             4.11 %       ±5.52%  ±7.35%  ±9.58%
util/text-decoder.js type='ArrayBuffer' n=100 len=16384 fatal=0 ignoreBOM=1 encoding='iso-8859-3'                       -1.43 %       ±4.67%  ±6.21%  ±8.09%
util/text-decoder.js type='ArrayBuffer' n=100 len=16384 fatal=0 ignoreBOM=1 encoding='latin1'                            0.39 %       ±5.40%  ±7.18%  ±9.34%
util/text-decoder.js type='ArrayBuffer' n=100 len=16384 fatal=0 ignoreBOM=1 encoding='utf-8'                            -3.35 %       ±6.27%  ±8.35% ±10.87%
util/text-decoder.js type='ArrayBuffer' n=100 len=16384 fatal=1 ignoreBOM=0 encoding='iso-8859-3'                        3.01 %       ±4.22%  ±5.62%  ±7.31%
util/text-decoder.js type='ArrayBuffer' n=100 len=16384 fatal=1 ignoreBOM=0 encoding='latin1'                            0.91 %       ±4.33%  ±5.77%  ±7.52%
util/text-decoder.js type='ArrayBuffer' n=100 len=16384 fatal=1 ignoreBOM=0 encoding='utf-8'                            -0.16 %       ±6.88%  ±9.16% ±11.93%
util/text-decoder.js type='ArrayBuffer' n=100 len=16384 fatal=1 ignoreBOM=1 encoding='iso-8859-3'                       -0.51 %       ±5.09%  ±6.77%  ±8.81%
util/text-decoder.js type='ArrayBuffer' n=100 len=16384 fatal=1 ignoreBOM=1 encoding='latin1'                           -2.31 %       ±5.84%  ±7.78% ±10.12%
util/text-decoder.js type='ArrayBuffer' n=100 len=16384 fatal=1 ignoreBOM=1 encoding='utf-8'                            -3.07 %       ±7.11%  ±9.46% ±12.31%
util/text-decoder.js type='ArrayBuffer' n=100 len=256 fatal=0 ignoreBOM=0 encoding='iso-8859-3'                          4.56 %      ±12.31% ±16.38% ±21.33%
util/text-decoder.js type='ArrayBuffer' n=100 len=256 fatal=0 ignoreBOM=0 encoding='latin1'                             -1.85 %      ±12.19% ±16.21% ±21.10%
util/text-decoder.js type='ArrayBuffer' n=100 len=256 fatal=0 ignoreBOM=0 encoding='utf-8'                               6.38 %      ±11.99% ±15.96% ±20.78%
util/text-decoder.js type='ArrayBuffer' n=100 len=256 fatal=0 ignoreBOM=1 encoding='iso-8859-3'                          4.95 %      ±11.90% ±15.84% ±20.62%
util/text-decoder.js type='ArrayBuffer' n=100 len=256 fatal=0 ignoreBOM=1 encoding='latin1'                              3.51 %      ±11.58% ±15.41% ±20.06%
util/text-decoder.js type='ArrayBuffer' n=100 len=256 fatal=0 ignoreBOM=1 encoding='utf-8'                               7.62 %       ±9.48% ±12.69% ±16.67%
util/text-decoder.js type='ArrayBuffer' n=100 len=256 fatal=1 ignoreBOM=0 encoding='iso-8859-3'                          1.72 %      ±10.24% ±13.63% ±17.74%
util/text-decoder.js type='ArrayBuffer' n=100 len=256 fatal=1 ignoreBOM=0 encoding='latin1'                              0.68 %      ±11.02% ±14.66% ±19.09%
util/text-decoder.js type='ArrayBuffer' n=100 len=256 fatal=1 ignoreBOM=0 encoding='utf-8'                               4.39 %      ±11.89% ±15.82% ±20.60%
util/text-decoder.js type='ArrayBuffer' n=100 len=256 fatal=1 ignoreBOM=1 encoding='iso-8859-3'                          7.65 %      ±12.17% ±16.21% ±21.11%
util/text-decoder.js type='ArrayBuffer' n=100 len=256 fatal=1 ignoreBOM=1 encoding='latin1'                             -3.24 %       ±8.65% ±11.53% ±15.06%
util/text-decoder.js type='ArrayBuffer' n=100 len=256 fatal=1 ignoreBOM=1 encoding='utf-8'                               4.37 %       ±9.34% ±12.45% ±16.25%
util/text-decoder.js type='ArrayBuffer' n=100 len=524288 fatal=0 ignoreBOM=0 encoding='iso-8859-3'                      -0.06 %       ±2.42%  ±3.22%  ±4.20%
util/text-decoder.js type='ArrayBuffer' n=100 len=524288 fatal=0 ignoreBOM=0 encoding='latin1'                          -0.44 %       ±1.46%  ±1.94%  ±2.52%
util/text-decoder.js type='ArrayBuffer' n=100 len=524288 fatal=0 ignoreBOM=0 encoding='utf-8'                            0.60 %       ±2.31%  ±3.08%  ±4.01%
util/text-decoder.js type='ArrayBuffer' n=100 len=524288 fatal=0 ignoreBOM=1 encoding='iso-8859-3'                       1.05 %       ±2.48%  ±3.30%  ±4.31%
util/text-decoder.js type='ArrayBuffer' n=100 len=524288 fatal=0 ignoreBOM=1 encoding='latin1'                          -0.92 %       ±2.33%  ±3.11%  ±4.07%
util/text-decoder.js type='ArrayBuffer' n=100 len=524288 fatal=0 ignoreBOM=1 encoding='utf-8'                            0.06 %       ±2.55%  ±3.40%  ±4.42%
util/text-decoder.js type='ArrayBuffer' n=100 len=524288 fatal=1 ignoreBOM=0 encoding='iso-8859-3'                *      2.32 %       ±2.04%  ±2.73%  ±3.56%
util/text-decoder.js type='ArrayBuffer' n=100 len=524288 fatal=1 ignoreBOM=0 encoding='latin1'                           1.57 %       ±3.10%  ±4.13%  ±5.38%
util/text-decoder.js type='ArrayBuffer' n=100 len=524288 fatal=1 ignoreBOM=0 encoding='utf-8'                           -2.39 %       ±2.58%  ±3.43%  ±4.46%
util/text-decoder.js type='ArrayBuffer' n=100 len=524288 fatal=1 ignoreBOM=1 encoding='iso-8859-3'                       0.22 %       ±1.36%  ±1.82%  ±2.37%
util/text-decoder.js type='ArrayBuffer' n=100 len=524288 fatal=1 ignoreBOM=1 encoding='latin1'                           0.17 %       ±1.91%  ±2.55%  ±3.32%
util/text-decoder.js type='ArrayBuffer' n=100 len=524288 fatal=1 ignoreBOM=1 encoding='utf-8'                            0.48 %       ±2.68%  ±3.56%  ±4.64%
util/text-decoder.js type='Buffer' n=100 len=16384 fatal=0 ignoreBOM=0 encoding='iso-8859-3'                             1.31 %       ±7.63% ±10.15% ±13.21%
util/text-decoder.js type='Buffer' n=100 len=16384 fatal=0 ignoreBOM=0 encoding='latin1'                                -1.47 %       ±4.79%  ±6.38%  ±8.31%
util/text-decoder.js type='Buffer' n=100 len=16384 fatal=0 ignoreBOM=0 encoding='utf-8'                                  2.48 %       ±4.62%  ±6.15%  ±8.00%
util/text-decoder.js type='Buffer' n=100 len=16384 fatal=0 ignoreBOM=1 encoding='iso-8859-3'                            -2.91 %       ±8.59% ±11.44% ±14.91%
util/text-decoder.js type='Buffer' n=100 len=16384 fatal=0 ignoreBOM=1 encoding='latin1'                                -3.63 %       ±4.39%  ±5.85%  ±7.62%
util/text-decoder.js type='Buffer' n=100 len=16384 fatal=0 ignoreBOM=1 encoding='utf-8'                                 -1.35 %       ±4.34%  ±5.78%  ±7.54%
util/text-decoder.js type='Buffer' n=100 len=16384 fatal=1 ignoreBOM=0 encoding='iso-8859-3'                             5.35 %      ±12.97% ±17.26% ±22.48%
util/text-decoder.js type='Buffer' n=100 len=16384 fatal=1 ignoreBOM=0 encoding='latin1'                                 0.85 %       ±5.05%  ±6.72%  ±8.75%
util/text-decoder.js type='Buffer' n=100 len=16384 fatal=1 ignoreBOM=0 encoding='utf-8'                                 -4.19 %      ±11.00% ±14.64% ±19.06%
util/text-decoder.js type='Buffer' n=100 len=16384 fatal=1 ignoreBOM=1 encoding='iso-8859-3'                             1.67 %      ±12.56% ±16.72% ±21.76%
util/text-decoder.js type='Buffer' n=100 len=16384 fatal=1 ignoreBOM=1 encoding='latin1'                                -1.42 %       ±4.87%  ±6.48%  ±8.44%
util/text-decoder.js type='Buffer' n=100 len=16384 fatal=1 ignoreBOM=1 encoding='utf-8'                                  1.86 %      ±11.22% ±14.93% ±19.43%
util/text-decoder.js type='Buffer' n=100 len=256 fatal=0 ignoreBOM=0 encoding='iso-8859-3'                              -0.21 %      ±12.83% ±17.06% ±22.21%
util/text-decoder.js type='Buffer' n=100 len=256 fatal=0 ignoreBOM=0 encoding='latin1'                                   1.16 %      ±11.10% ±14.77% ±19.24%
util/text-decoder.js type='Buffer' n=100 len=256 fatal=0 ignoreBOM=0 encoding='utf-8'                                   -1.30 %      ±11.49% ±15.29% ±19.91%
util/text-decoder.js type='Buffer' n=100 len=256 fatal=0 ignoreBOM=1 encoding='iso-8859-3'                       **    -14.95 %       ±9.46% ±12.73% ±16.86%
util/text-decoder.js type='Buffer' n=100 len=256 fatal=0 ignoreBOM=1 encoding='latin1'                                   8.59 %      ±11.11% ±14.79% ±19.28%
util/text-decoder.js type='Buffer' n=100 len=256 fatal=0 ignoreBOM=1 encoding='utf-8'                                   -2.07 %       ±6.12%  ±8.15% ±10.65%
util/text-decoder.js type='Buffer' n=100 len=256 fatal=1 ignoreBOM=0 encoding='iso-8859-3'                               8.23 %      ±12.32% ±16.40% ±21.38%
util/text-decoder.js type='Buffer' n=100 len=256 fatal=1 ignoreBOM=0 encoding='latin1'                                   3.64 %      ±12.49% ±16.62% ±21.65%
util/text-decoder.js type='Buffer' n=100 len=256 fatal=1 ignoreBOM=0 encoding='utf-8'                                   -1.71 %       ±8.37% ±11.14% ±14.50%
util/text-decoder.js type='Buffer' n=100 len=256 fatal=1 ignoreBOM=1 encoding='iso-8859-3'                              -4.67 %      ±13.44% ±17.93% ±23.42%
util/text-decoder.js type='Buffer' n=100 len=256 fatal=1 ignoreBOM=1 encoding='latin1'                                  -1.72 %      ±12.78% ±17.01% ±22.14%
util/text-decoder.js type='Buffer' n=100 len=256 fatal=1 ignoreBOM=1 encoding='utf-8'                                   -6.56 %       ±9.01% ±11.99% ±15.62%
util/text-decoder.js type='Buffer' n=100 len=524288 fatal=0 ignoreBOM=0 encoding='iso-8859-3'                            0.02 %       ±1.60%  ±2.13%  ±2.77%
util/text-decoder.js type='Buffer' n=100 len=524288 fatal=0 ignoreBOM=0 encoding='latin1'                                0.47 %       ±2.16%  ±2.88%  ±3.76%
util/text-decoder.js type='Buffer' n=100 len=524288 fatal=0 ignoreBOM=0 encoding='utf-8'                                 1.16 %       ±2.47%  ±3.29%  ±4.29%
util/text-decoder.js type='Buffer' n=100 len=524288 fatal=0 ignoreBOM=1 encoding='iso-8859-3'                            0.13 %       ±1.63%  ±2.18%  ±2.84%
util/text-decoder.js type='Buffer' n=100 len=524288 fatal=0 ignoreBOM=1 encoding='latin1'                               -2.10 %       ±3.83%  ±5.15%  ±6.82%
util/text-decoder.js type='Buffer' n=100 len=524288 fatal=0 ignoreBOM=1 encoding='utf-8'                                -0.99 %       ±2.20%  ±2.92%  ±3.80%
util/text-decoder.js type='Buffer' n=100 len=524288 fatal=1 ignoreBOM=0 encoding='iso-8859-3'                            0.78 %       ±2.76%  ±3.71%  ±4.88%
util/text-decoder.js type='Buffer' n=100 len=524288 fatal=1 ignoreBOM=0 encoding='latin1'                                1.27 %       ±1.32%  ±1.76%  ±2.29%
util/text-decoder.js type='Buffer' n=100 len=524288 fatal=1 ignoreBOM=0 encoding='utf-8'                                -1.02 %       ±2.53%  ±3.37%  ±4.38%
util/text-decoder.js type='Buffer' n=100 len=524288 fatal=1 ignoreBOM=1 encoding='iso-8859-3'                            0.60 %       ±1.72%  ±2.30%  ±3.01%
util/text-decoder.js type='Buffer' n=100 len=524288 fatal=1 ignoreBOM=1 encoding='latin1'                               -1.05 %       ±1.82%  ±2.44%  ±3.19%
util/text-decoder.js type='Buffer' n=100 len=524288 fatal=1 ignoreBOM=1 encoding='utf-8'                                 0.27 %       ±2.81%  ±3.74%  ±4.86%
util/text-decoder.js type='SharedArrayBuffer' n=100 len=16384 fatal=0 ignoreBOM=0 encoding='iso-8859-3'                  2.97 %       ±5.27%  ±7.01%  ±9.14%
util/text-decoder.js type='SharedArrayBuffer' n=100 len=16384 fatal=0 ignoreBOM=0 encoding='latin1'                     -2.84 %       ±4.23%  ±5.62%  ±7.32%
util/text-decoder.js type='SharedArrayBuffer' n=100 len=16384 fatal=0 ignoreBOM=0 encoding='utf-8'                      -3.12 %       ±6.49%  ±8.63% ±11.24%
util/text-decoder.js type='SharedArrayBuffer' n=100 len=16384 fatal=0 ignoreBOM=1 encoding='iso-8859-3'                  3.51 %       ±5.11%  ±6.81%  ±8.86%
util/text-decoder.js type='SharedArrayBuffer' n=100 len=16384 fatal=0 ignoreBOM=1 encoding='latin1'                     -0.16 %       ±4.61%  ±6.14%  ±8.00%
util/text-decoder.js type='SharedArrayBuffer' n=100 len=16384 fatal=0 ignoreBOM=1 encoding='utf-8'                       4.46 %       ±6.22%  ±8.28% ±10.80%
util/text-decoder.js type='SharedArrayBuffer' n=100 len=16384 fatal=1 ignoreBOM=0 encoding='iso-8859-3'                  2.83 %       ±5.50%  ±7.32%  ±9.52%
util/text-decoder.js type='SharedArrayBuffer' n=100 len=16384 fatal=1 ignoreBOM=0 encoding='latin1'                      1.54 %       ±5.22%  ±6.96%  ±9.07%
util/text-decoder.js type='SharedArrayBuffer' n=100 len=16384 fatal=1 ignoreBOM=0 encoding='utf-8'                       0.65 %       ±7.04%  ±9.36% ±12.19%
util/text-decoder.js type='SharedArrayBuffer' n=100 len=16384 fatal=1 ignoreBOM=1 encoding='iso-8859-3'                  0.06 %       ±5.21%  ±6.93%  ±9.02%
util/text-decoder.js type='SharedArrayBuffer' n=100 len=16384 fatal=1 ignoreBOM=1 encoding='latin1'                      1.54 %       ±5.27%  ±7.01%  ±9.12%
util/text-decoder.js type='SharedArrayBuffer' n=100 len=16384 fatal=1 ignoreBOM=1 encoding='utf-8'                       4.41 %       ±6.21%  ±8.26% ±10.75%
util/text-decoder.js type='SharedArrayBuffer' n=100 len=256 fatal=0 ignoreBOM=0 encoding='iso-8859-3'                    8.12 %      ±11.91% ±15.86% ±20.68%
util/text-decoder.js type='SharedArrayBuffer' n=100 len=256 fatal=0 ignoreBOM=0 encoding='latin1'                        6.66 %      ±10.31% ±13.74% ±17.91%
util/text-decoder.js type='SharedArrayBuffer' n=100 len=256 fatal=0 ignoreBOM=0 encoding='utf-8'                        -1.00 %       ±7.70% ±10.24% ±13.34%
util/text-decoder.js type='SharedArrayBuffer' n=100 len=256 fatal=0 ignoreBOM=1 encoding='iso-8859-3'                    4.71 %      ±11.09% ±14.77% ±19.24%
util/text-decoder.js type='SharedArrayBuffer' n=100 len=256 fatal=0 ignoreBOM=1 encoding='latin1'                        0.59 %      ±11.95% ±15.90% ±20.69%
util/text-decoder.js type='SharedArrayBuffer' n=100 len=256 fatal=0 ignoreBOM=1 encoding='utf-8'                         6.49 %      ±11.81% ±15.73% ±20.50%
util/text-decoder.js type='SharedArrayBuffer' n=100 len=256 fatal=1 ignoreBOM=0 encoding='iso-8859-3'                   10.24 %      ±13.23% ±17.61% ±22.93%
util/text-decoder.js type='SharedArrayBuffer' n=100 len=256 fatal=1 ignoreBOM=0 encoding='latin1'                        4.25 %      ±12.54% ±16.69% ±21.75%
util/text-decoder.js type='SharedArrayBuffer' n=100 len=256 fatal=1 ignoreBOM=0 encoding='utf-8'                        -7.38 %      ±10.20% ±13.59% ±17.73%
util/text-decoder.js type='SharedArrayBuffer' n=100 len=256 fatal=1 ignoreBOM=1 encoding='iso-8859-3'                    2.06 %      ±11.34% ±15.09% ±19.64%
util/text-decoder.js type='SharedArrayBuffer' n=100 len=256 fatal=1 ignoreBOM=1 encoding='latin1'                        2.34 %      ±11.11% ±14.78% ±19.25%
util/text-decoder.js type='SharedArrayBuffer' n=100 len=256 fatal=1 ignoreBOM=1 encoding='utf-8'                         2.33 %      ±11.27% ±15.00% ±19.52%
util/text-decoder.js type='SharedArrayBuffer' n=100 len=524288 fatal=0 ignoreBOM=0 encoding='iso-8859-3'                -0.51 %       ±2.31%  ±3.09%  ±4.05%
util/text-decoder.js type='SharedArrayBuffer' n=100 len=524288 fatal=0 ignoreBOM=0 encoding='latin1'                    -0.48 %       ±1.53%  ±2.04%  ±2.65%
util/text-decoder.js type='SharedArrayBuffer' n=100 len=524288 fatal=0 ignoreBOM=0 encoding='utf-8'                     -1.20 %       ±2.76%  ±3.67%  ±4.78%
util/text-decoder.js type='SharedArrayBuffer' n=100 len=524288 fatal=0 ignoreBOM=1 encoding='iso-8859-3'                 0.44 %       ±1.28%  ±1.71%  ±2.22%
util/text-decoder.js type='SharedArrayBuffer' n=100 len=524288 fatal=0 ignoreBOM=1 encoding='latin1'                     0.68 %       ±1.74%  ±2.32%  ±3.02%
util/text-decoder.js type='SharedArrayBuffer' n=100 len=524288 fatal=0 ignoreBOM=1 encoding='utf-8'               *     -2.41 %       ±2.29%  ±3.04%  ±3.96%
util/text-decoder.js type='SharedArrayBuffer' n=100 len=524288 fatal=1 ignoreBOM=0 encoding='iso-8859-3'                -1.31 %       ±2.65%  ±3.53%  ±4.59%
util/text-decoder.js type='SharedArrayBuffer' n=100 len=524288 fatal=1 ignoreBOM=0 encoding='latin1'                     1.06 %       ±2.77%  ±3.72%  ±4.90%
util/text-decoder.js type='SharedArrayBuffer' n=100 len=524288 fatal=1 ignoreBOM=0 encoding='utf-8'                     -0.60 %       ±2.69%  ±3.58%  ±4.66%
util/text-decoder.js type='SharedArrayBuffer' n=100 len=524288 fatal=1 ignoreBOM=1 encoding='iso-8859-3'                 0.02 %       ±1.56%  ±2.08%  ±2.71%
util/text-decoder.js type='SharedArrayBuffer' n=100 len=524288 fatal=1 ignoreBOM=1 encoding='latin1'                     0.10 %       ±1.43%  ±1.90%  ±2.47%
util/text-decoder.js type='SharedArrayBuffer' n=100 len=524288 fatal=1 ignoreBOM=1 encoding='utf-8'               *     -2.97 %       ±2.27%  ±3.02%  ±3.94%
util/text-encoder.js op='encode' type='ascii' n=1000000 len=1024                                                         0.06 %       ±1.41%  ±1.88%  ±2.45%
util/text-encoder.js op='encode' type='ascii' n=1000000 len=256                                                          0.84 %       ±1.19%  ±1.59%  ±2.07%
util/text-encoder.js op='encode' type='ascii' n=1000000 len=32                                                          -0.68 %       ±1.60%  ±2.13%  ±2.77%
util/text-encoder.js op='encode' type='ascii' n=1000000 len=8192                                                        -0.32 %       ±0.77%  ±1.02%  ±1.33%
util/text-encoder.js op='encode' type='one-byte-string' n=1000000 len=1024                                               0.52 %       ±1.13%  ±1.50%  ±1.96%
util/text-encoder.js op='encode' type='one-byte-string' n=1000000 len=256                                               -0.73 %       ±1.37%  ±1.82%  ±2.37%
util/text-encoder.js op='encode' type='one-byte-string' n=1000000 len=32                                                 0.01 %       ±1.27%  ±1.69%  ±2.19%
util/text-encoder.js op='encode' type='one-byte-string' n=1000000 len=8192                                              -0.21 %       ±0.32%  ±0.43%  ±0.56%
util/text-encoder.js op='encode' type='two-byte-string' n=1000000 len=1024                                               0.08 %       ±0.71%  ±0.95%  ±1.24%
util/text-encoder.js op='encode' type='two-byte-string' n=1000000 len=256                                         *     -1.28 %       ±1.02%  ±1.36%  ±1.77%
util/text-encoder.js op='encode' type='two-byte-string' n=1000000 len=32                                                -0.54 %       ±1.79%  ±2.38%  ±3.10%
util/text-encoder.js op='encode' type='two-byte-string' n=1000000 len=8192                                               0.09 %       ±0.13%  ±0.18%  ±0.23%
util/text-encoder.js op='encodeInto' type='ascii' n=1000000 len=1024                                                    -0.70 %       ±4.28%  ±5.69%  ±7.41%
util/text-encoder.js op='encodeInto' type='ascii' n=1000000 len=256                                               *     -6.35 %       ±5.69%  ±7.57%  ±9.85%
util/text-encoder.js op='encodeInto' type='ascii' n=1000000 len=32                                                      -5.96 %       ±7.11%  ±9.47% ±12.33%
util/text-encoder.js op='encodeInto' type='ascii' n=1000000 len=8192                                              *      2.62 %       ±2.44%  ±3.24%  ±4.22%
util/text-encoder.js op='encodeInto' type='one-byte-string' n=1000000 len=1024                                           0.74 %       ±1.85%  ±2.46%  ±3.20%
util/text-encoder.js op='encodeInto' type='one-byte-string' n=1000000 len=256                                           -2.70 %       ±5.49%  ±7.30%  ±9.50%
util/text-encoder.js op='encodeInto' type='one-byte-string' n=1000000 len=32                                             0.24 %       ±9.44% ±12.55% ±16.34%
util/text-encoder.js op='encodeInto' type='one-byte-string' n=1000000 len=8192                                           0.05 %       ±0.32%  ±0.43%  ±0.56%
util/text-encoder.js op='encodeInto' type='two-byte-string' n=1000000 len=1024                                          -0.87 %       ±1.20%  ±1.59%  ±2.08%
util/text-encoder.js op='encodeInto' type='two-byte-string' n=1000000 len=256                                     *     -5.42 %       ±5.03%  ±6.69%  ±8.71%
util/text-encoder.js op='encodeInto' type='two-byte-string' n=1000000 len=32                                             1.38 %       ±8.25% ±10.97% ±14.28%
util/text-encoder.js op='encodeInto' type='two-byte-string' n=1000000 len=8192                                           0.11 %       ±0.19%  ±0.25%  ±0.32%
util/to-usv-string.js size=10 n=100000                                                                                   2.51 %       ±6.97%  ±9.29% ±12.10%
util/to-usv-string.js size=100 n=100000                                                                                 -4.62 %       ±7.49%  ±9.96% ±12.97%
util/to-usv-string.js size=500 n=100000                                                                                 -0.12 %       ±1.81%  ±2.41%  ±3.13%
util/type-check.js n=100000 argument='false-object' version='js' type='ArrayBufferView'                                 -0.54 %       ±8.65% ±11.51% ±14.99%
util/type-check.js n=100000 argument='false-object' version='js' type='TypedArray'                                       6.76 %       ±7.07%  ±9.42% ±12.28%
util/type-check.js n=100000 argument='false-object' version='js' type='Uint8Array'                                      -0.68 %       ±6.43%  ±8.56% ±11.15%
util/type-check.js n=100000 argument='false-object' version='native' type='ArrayBufferView'                      **    -10.46 %       ±7.00%  ±9.34% ±12.24%
util/type-check.js n=100000 argument='false-object' version='native' type='TypedArray'                                  -1.47 %       ±6.60%  ±8.78% ±11.44%
util/type-check.js n=100000 argument='false-object' version='native' type='Uint8Array'                                   2.93 %       ±7.91% ±10.52% ±13.69%
util/type-check.js n=100000 argument='false-primitive' version='js' type='ArrayBufferView'                              -3.53 %       ±8.89% ±11.82% ±15.39%
util/type-check.js n=100000 argument='false-primitive' version='js' type='TypedArray'                                    0.03 %       ±6.50%  ±8.65% ±11.26%
util/type-check.js n=100000 argument='false-primitive' version='js' type='Uint8Array'                                   -3.35 %       ±7.91% ±10.54% ±13.72%
util/type-check.js n=100000 argument='false-primitive' version='native' type='ArrayBufferView'                    *     10.39 %       ±9.93% ±13.21% ±17.19%
util/type-check.js n=100000 argument='false-primitive' version='native' type='TypedArray'                               -0.56 %       ±6.95%  ±9.24% ±12.03%
util/type-check.js n=100000 argument='false-primitive' version='native' type='Uint8Array'                                0.54 %       ±7.87% ±10.47% ±13.63%
util/type-check.js n=100000 argument='true' version='js' type='ArrayBufferView'                                         -7.91 %       ±8.17% ±10.88% ±14.20%
util/type-check.js n=100000 argument='true' version='js' type='TypedArray'                                              -0.54 %       ±6.36%  ±8.46% ±11.01%
util/type-check.js n=100000 argument='true' version='js' type='Uint8Array'                                              -0.64 %       ±7.04%  ±9.36% ±12.19%
util/type-check.js n=100000 argument='true' version='native' type='ArrayBufferView'                                      1.95 %      ±10.72% ±14.26% ±18.56%
util/type-check.js n=100000 argument='true' version='native' type='TypedArray'                                          -1.26 %       ±5.60%  ±7.45%  ±9.69%
util/type-check.js n=100000 argument='true' version='native' type='Uint8Array'                                           3.76 %       ±7.89% ±10.50% ±13.68%

Be aware that when doing many comparisons the risk of a false-positive
result increases. In this case, there are 248 comparisons, you can thus
expect the following amount of false-positive results:
  12.40 false positives, when considering a   5% risk acceptance (*, **, ***),
  2.48 false positives, when considering a   1% risk acceptance (**, ***),
  0.25 false positives, when considering a 0.1% risk acceptance (***)

@nodejs-github-bot
Copy link
Collaborator

@H4ad H4ad added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. commit-queue Add this label to land a pull request using GitHub Actions. and removed commit-queue Add this label to land a pull request using GitHub Actions. labels Nov 16, 2023
@H4ad
Copy link
Member

H4ad commented Nov 16, 2023

@zhenweijin Thanks for the PR, I updated the description to use the Benchmark CI Results.

@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Nov 16, 2023
@nodejs-github-bot nodejs-github-bot merged commit daf723a into nodejs:main Nov 16, 2023
@nodejs-github-bot
Copy link
Collaborator

Landed in daf723a

targos pushed a commit that referenced this pull request Nov 23, 2023
PR-URL: #50721
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
martenrichter pushed a commit to martenrichter/node that referenced this pull request Nov 26, 2023
PR-URL: nodejs#50721
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
@RafaelGSS RafaelGSS mentioned this pull request Nov 28, 2023
UlisesGascon pushed a commit that referenced this pull request Dec 11, 2023
PR-URL: #50721
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
@UlisesGascon UlisesGascon mentioned this pull request Dec 12, 2023
UlisesGascon pushed a commit that referenced this pull request Dec 19, 2023
PR-URL: #50721
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. needs-ci PRs that need a full CI run. util Issues and PRs related to the built-in util module.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants