Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re: Testing objects that cache

by rir (Vicar)
on May 15, 2009 at 17:41 UTC ( #764321=note: print w/replies, xml ) Need Help??

in reply to Testing objects that cache

Scaling up the load of your normal tests will show if your code "works" in a pragmatic sense. That is difficult in your case or you have undisclosed motives.

Using Devel::Cover could verify that your caching code is being exercised.

If your cache is implemented with a call tree, i.e.

sub fetch { return _cached_fetch($_[1]) if _cached( $_[1] ); return _via_normal_retrieval( $_[1] ); }
there are packages that will insert code at the entry or exit of a set of routines. This would let you insert a logging function into fetch and _cached_fetch to generate statistics on cache performance. I cannot think of the name for this type of function modification.

The insert code could be something like

sub log_cache { local $, = " "; print SOMEWHERE "MyObj cache called", caller(1), "w/",$_[1],$/; }
cleaned up for log readability.

Be well,

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://764321]
[ambrus]: was this bug: https://rt.cpan. org/Public/Bug/ Display.html?id= 59814
[Corion]: ambrus: Oh - that one would be much harder to automate... The SYNOPSIS section should mostly be a runnable program IMO, but I write only small snippets in my documentation for single functions/methods, and creating the appropriate environment for ...
[Corion]: ... those in an automated fashion seems somewhat hard to me. Although it should do wonders for the test coverage ;)
[haukex]: Corion: I once wrote an automated thingy for that here
[haukex]: here's the code that uses it
[Corion]: haukex: Hmm - maybe I can reuse that. I see that it uses Pod::Parser, which I think was one of the more fragile parsers. But if I'm statically (re)generating the tests instead of doing that "live" on the client/tester machines, that's a much smaller...
[Corion]: ... problem space than trying to cater to all versions of Pod::Parser(s)

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (10)
As of 2017-02-27 12:20 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (385 votes). Check out past polls.