medikoo / memoizee

Complete memoize/cache solution for JavaScript
ISC License
1.73k stars 61 forks source link

Naming cache buckets for profiling #82

Closed hem-brahmbhatt closed 7 years ago

hem-brahmbhatt commented 7 years ago

When wrapping calls to memoizee in a module, the profile records all calls under a single bucket for the module.

------------------------------------------------------------
Memoize statistics:

Init  Cache  %Cache  Source location
  17     12   41.38  (all)
  17     12   41.38  at cache (/Users/test/Projects/test/src/data/cache.js:14:10)
------------------------------------------------------------

Having a parameter to specify to name the bucket would be useful.

memProfile = require('memoizee/profile');
memoized = memoize(fn, { name: "My bucket" });
console.log(memProfile.log());

------------------------------------------------------------
Memoize statistics:

Init  Cache  %Cache  Name
  17     12   41.38  (all)
  17     12   41.38  My bucket
------------------------------------------------------------

Wrappers could then pass this through to memoizee and can be used instead of the source location.

medikoo commented 7 years ago

Ok, so some profileName option, to replace location of initialization.

Good proposal, I'll keep it in the backlog. Thanks