<script src="https://pkgzip.com/bundle.js?packages=memoize-one@1.0.2,fast-memoize@2.2.0,underscore@1.8.3,lodash@4.17.4,moize@2.2.1,memoizejs@0.1.1,moize@2.2.1,reselect@2.5.4"></script>
var fn = function() {
for(var i = 0; i < 2000; i++) {
void(undefined);
}
}
var modules = window.pkgzip;
var memoizeOneFn = modules.memoizeOne.default(fn);
var fastMemoizeFn = modules.fastMemoize(fn);
var underscoreFn = modules.underscore.memoize(fn);
var lodashFn = modules.lodash.memoize(fn);
var memoizejsFn = modules.memoizejs(fn);
var reselectFn = modules.reselect.defaultMemoize(fn);
var moizeFn = modules.moize(fn);
var arg = {foo: 'bar'}
fn(arg);
memoizeOneFn(arg);
fastMemoizeFn(arg);
lodashFn(arg);
underscoreFn(arg);
memoizejsFn(arg);
reselectFn(arg);
moizeFn(arg)
--enable-precise-memory-info
flag.
Test case name | Result |
---|---|
baseline | |
memoizeOne | |
fastMemoize | |
lodash | |
underscore | |
memoizejs | |
reselect | |
moize |
Test name | Executions per second |
---|---|
baseline | 2838.3 Ops/sec |
memoizeOne | 3810030.2 Ops/sec |
fastMemoize | 823358.8 Ops/sec |
lodash | 2932248.2 Ops/sec |
underscore | 2801215.8 Ops/sec |
memoizejs | 834046.5 Ops/sec |
reselect | 3507489.0 Ops/sec |
moize | 4666812.5 Ops/sec |
Let's dive into the world of memoization and explore what's being tested in this benchmark.
Memoization: A brief introduction
Memoization is an optimization technique that stores the results of expensive function calls so that they can be reused instead of recalculated. This technique can significantly improve performance in situations where a function is called with the same inputs multiple times.
The benchmark's purpose
In this benchmark, we're comparing the performance of different memoization libraries: memoizeOne
, fastMemoize
, lodash.memoize
, and others. The goal is to determine which library provides the best performance for a specific use case (in this case, a simple function with complex types).
Options compared
The following options are being compared:
memoizeOne
: A custom implementation of memoization.fastMemoize
: A fast memoization library that likely uses various optimization techniques to improve performance.lodash.memoize
and underscore.memoize
: Memoization functions provided by the popular lodash
and underscore
libraries, respectively.Pros and Cons
Here's a brief summary of each option:
Other considerations
The benchmark also includes a "baseline" test, which calls the original function without memoization. This helps establish a lower bound for performance comparison.
Special JS feature or syntax
There's no special JavaScript feature or syntax being tested in this benchmark. The focus is on comparing different memoization libraries and their implementations.
Library descriptions
Here are brief descriptions of each library mentioned:
lodash
and underscore
, respectively.I hope this helps you understand the benchmark's purpose and comparisons!