Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^3: Class::Std::Fast cache and threads

by Boldra (Deacon)
on Oct 13, 2010 at 15:35 UTC ( #865104=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Class::Std::Fast cache and threads
in thread Class::Std::Fast cache and threads

Definitely a good point. I haven't tested it myself, insteadI'm trusting the claims of the CSF author who says it's "an order of magnitude faster". You may have missed is that it's caching a blessed scalar ref, which means that on the next new call, it can just pop an item of the cache instead of blessing a new object. This is apparently where the speed saving comes from.

I'm also a bit stuck with the problem that the caching is set at import in about 20 SOAP::WSDL::XSD::Typelib::Builtin::* modules (and possibly other modules autogenerated by wsdl2perl). I'm sticking with my "caching is faster" excuse for now though - I'll switch to "I'm too lazy" when I get desperate :)


Comment on Re^3: Class::Std::Fast cache and threads
Re^4: Class::Std::Fast cache and threads
by BrowserUk (Pope) on Oct 13, 2010 at 15:52 UTC
    You may have missed is that it's caching a blessed scalar ref, which means that on the next new call, it can just pop an item of the cache instead of blessing a new object.

    Blessing a ref takes an infinitesimal amount of time. My benchmark:

    package STR; use Class::Std::Fast; ## cache => 1; package main; use Time::HiRes qw[ time ]; my $start = time; STR->new for 1 .. 1e6; printf "Took %.8f seconds\n", ( time - $start ) / 1e6; __END__ ## With caching c:\test>junk64 Took 0.00002447 seconds ## Without caching c:\test>junk64 Took 0.00002391 seconds

    And if you removed all the cache related conditionals, it would be quicker still.

    It would also avoid your original problem


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://865104]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2014-12-19 02:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (70 votes), past polls