No such thing as a small change | |
PerlMonks |
use Memoize;by Anonymous Monk |
on Jul 16, 2018 at 19:18 UTC ( [id://1218607]=perlmeditation: print w/replies, xml ) | Need Help?? |
I was porting a script to a module and noticed it kept getting slower.
The script could initialize its expensive data structure once at the
top and be done with it, but in order to encapsulate, the module was
calling the function several times. I remembered the core module
Memoize and added one line to the top of the program and now it runs fast again, 4x faster than without Memoize!
use Memoize; memoize('some_sub');Only 1.5 seconds to start a program that was taking 6 seconds!
Back to
Meditations
|
|