Skip to content

buffer: make indexOf(byte) faster

Add a V8 fast API implementation for indexOfNumber, which significantly improves the performance of finding a single byte within a buffer.

Local benchmark:

                                                    confidence improvement accuracy (*)   (**)  (***)
buffers/buffer-indexof-number.js n=1000000 value=64        ***     57.69 %       ±5.47% ±7.29% ±9.52%

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

Refs: https://github.com/nodejs/node/pull/52993

Merge request reports

Loading