Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

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

by BrowserUk (Patriarch)
on Oct 13, 2010 at 15:52 UTC ( [id://865108]=note: print w/replies, xml ) Need Help??


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

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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://865108]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2024-04-19 03:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found