Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^7: A Scalar::Util::refaddr Oddity

by adrianh (Chancellor)
on Sep 27, 2005 at 13:08 UTC ( [id://495361]=note: print w/replies, xml ) Need Help??


in reply to Re^6: A Scalar::Util::refaddr Oddity
in thread A Scalar::Util::refaddr Oddity

You're the benchmark master. ;-) One-time hit to require overload and then a single function call, or always check blessed, store the original package and bless twice?

No idea :-) I was thinking of memory footprint rather than speed myself... but you're right. Capital mistake to theorise ahead of data and all that.

Replies are listed 'Best First'.
Re^8: A Scalar::Util::refaddr Oddity
by xdg (Monsignor) on Sep 27, 2005 at 15:43 UTC

    I'm trying to remember to benchmark more myself. Some quick benchmarking I did suggests they're all within the margin of error. Rest deleted

    Update: Error is in front of keyboard. There's a big difference if I actually write my benchmark code correctly.

    (Each loop did a refaddr on one object, one hash ref, and one ref to a constant.)

    # overload used on object Rate bless_regex strval_0+ bless_0+ bless_regex 12921/s -- -34% -37% strval_0+ 19557/s 51% -- -5% bless_0+ 20495/s 59% 5% -- # no overloading ( and overload not loaded ) Rate bless_regex bless_0+ strval_0+ bless_regex 13504/s -- -35% -93% bless_0+ 20766/s 54% -- -90% strval_0+ 206767/s 1431% 896% -- # bless_regex: fixed PP version from Scalar::Util to store package usi +ng PP blessed, and only rebless if reference is blessed # bless_0+: same as above, but use 0+$ref instead of regex extraction # strval_0+: if overload loaded and reference is overloaded, use StrVa +l to extract with regex, otherwise, use 0+$ref

    -xdg

    Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2024-04-25 23:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found