in reply to How to test caching?

There are two things I can think about:

As the first option just benchmark it. If something costly is actually costly, you can run it a few times and check if the run time is that of a few hash look ups or of doing something costly a few times. Particularly compare the time for the first call to subsequent calls.

The second idea is to use PadWalker to peek into the sub's lexical pad.

That being said caching is a mechanism that can easily be factored out (Memoize) and tested separately, so usually you don't need that sort of test at all.

Replies are listed 'Best First'.
A reply falls below the community's threshold of quality. You may see it by logging in.