How would you write a test that checks whether the cache is actually used? Clearly you cannot access %cache to test as its lexical in the sub.sub foo ($) { my $arg = shift; state %cache; return $cache{$arg} if exists $cache{$arg}; my $result = ... something costly ...; $cache{$arg} = $result; }
BTW, I know about Memoize. But "use Memoize" isn't an answer to the question.
In reply to How to test caching? by JavaFan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |