dai-shi / proxy-memoize

Intuitive magical memoization library with Proxy and WeakMap

Home Page:http://proxy-memoize.js.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Performance drop after update from 1.0.0 to 1.1.0

Bardiamist opened this issue · comments

Here is small example:

const memoize = require('proxy-memoize');

const reduxState = {
  books: [],
};

for (let index = 0; index < 1000; index += 1) {
  reduxState.books.push({
    isActive: true,
  });
}

const selectActiveBooks = memoize(({
  books,
}) => books.filter((book) => book.active));

selectActiveBooks(reduxState);

const nextReduxState = { ...reduxState, b: '' };

for (let index = 0; index < 100; index += 1) {
  const startTime = performance.now();
  selectActiveBooks(nextReduxState);
  console.log(performance.now() - startTime);
}

Selectors from this example on my machine takes:
v1.0.0: 0.0005 ms
v1.1.0: 0.09 ms
v2.0.0: 0.1 ms

Previous issue

Please try to fix/optimize it

Thanks for the benchmarking example. That's very helpful.
#60 should fix it.
https://ci.codesandbox.io/status/dai-shi/proxy-memoize/pr/60
See "Local Install Instructions" ☝️

Nice! Looks good
Takes 0.0003 ms on my machine