src/benchmarks.js measures performance of filtering an already sorted list of elements.
The list is 1 million items long, the predicate matches after the first 10 items (i.e. relatively early).
Thus, the following expectations arise:
-
filterwill be slow because it always needs to traverse the complete list -
skipUntilandfindIndexshould be:-
faster than
filter -
both be of similar performance
-
These expectations hold true for 3.8.2 but not for 4.0.0-rc.12, potentially indicating a regression.
yarn install
yarn run startCompare 4.0.0-rc.12 and 3.8.2 (change version in package.json)
macOS Mojave, 2.9 GHz Intel Core i9, node v12.9.1
via filter:
6 ops/s, ±11.66% | 100% slower
via skipUntil:
5 ops/s, ±7.81% | slowest, 100% slower
via findIndex/takeLast:
680 918 ops/s, ±5.81% | fastest