README.md

June 17, 2023 · View on GitHub

Benchmarks

Running Benchmarks

To run the benchmark script:

npm run benchmark

Benchmark Results (2019)

The following benchmark results which are outdated and may not accurately reflect all scenarios, so you're encouraged to run the benchmarks yourself or perform performance analysis in your own application.

In particular:

  • Because Memize is implemented as a least recently used (LRU) cache, it is optimized for scenarios where the function is called repeatedly with the same arguments. If arguments are less predictable in your usage, the performance benefit may not be as great.
  • The included benchmarking script is naive and does not incorporate any randomization of arguments.

The following benchmarks are performed in Node 10.16.0 on a MacBook Pro (2019), 2.4 GHz 8-Core Intel Core i9, 32 GB 2400 MHz DDR4 RAM.

Single argument

NameOps / secRelative margin of errorSample size
fast-memoize360,812,575± 0.55%87
memize128,909,282± 1.06%87
moize102,858,648± 0.66%88
lru-memoize71,589,564± 0.90%88
lodash49,575,743± 1.00%88
underscore35,805,268± 0.86%88
memoizee35,357,004± 0.55%87
moize (serialized)27,246,184± 0.88%87
memoizerific8,647,735± 0.91%91
ramda8,011,334± 0.74%90
memoizejs2,111,745± 0.52%88

* Note: fast-memoize uses Function.length to optimize for singular argument functions, which can yield unexpected behavior if not account for.

Multiple arguments (primitive)

NameOps / secRelative margin of errorSample size
memize81,460,517± 0.61%88
moize66,896,395± 0.90%83
lru-memoize26,315,198± 1.26%85
memoizee18,237,056± 0.60%90
moize (serialized)15,207,105± 0.78%84
memoizerific6,363,555± 0.63%88
memoizejs1,764,673± 0.57%90
fast-memoize1,560,421± 0.72%87

Multiple arguments (non-primitive)

NameOps / secRelative margin of errorSample size
memize79,105,918± 0.81%86
moize62,374,610± 0.55%87
lru-memoize24,814,747± 0.54%89
memoizee12,119,005± 0.47%89
memoizerific6,748,675± 0.66%88
moize (serialized)2,027,250± 1.07%87
fast-memoize1,263,457± 1.00%89
memoizejs1,075,690± 0.61%87