Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re^2: Tied Hashes vs. Objects

by Anonymous Monk
on Oct 22, 2012 at 19:14 UTC ( #1000407=note: print w/replies, xml ) Need Help??

in reply to Re: Tied Hashes vs. Objects
in thread Tied Hashes vs. Objects

Thank you very much, this was exactly the kind of advice I was seeking. In some circles, I think, tied hashes have for some reasons gained a bad reputation, performance-wise. I could not find any references backing this, so unless proven otherwise, I'll stick with tied hashes, as you sugested.

Replies are listed 'Best First'.
Re^3: Tied Hashes vs. Objects
by BrowserUk (Pope) on Oct 22, 2012 at 21:31 UTC

    As it had been a long time since I'd performed this kind of benchmark, I did one:

    The results:

    __END__ C:\test> 8376437/16777216 std hash usage took: 56.582 seconds 8376437/16777216 tied usage took: 210.352 seconds 8376437/16777216 Object usage took: 126.642 seconds

    show that using the object interface saves 1 microsecond per key, spread across all 5 operations performed on each key/value, Say 1/5th of a microsecond (0.0000002) per operation. You need to be doing billions of hash operations -- with almost no other associated processing -- for that to become a significant part of your time costs.

    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    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.

    RIP Neil Armstrong

      Thank you very much for your effort!

      At least to me, this really busts the "Tied Hashes are Expensive" myth, so the decision whether to use tied hashes or an object interface should definitely not be based on performance, but rather on matters of style and clarity. Thanks again!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1000407]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2018-05-21 11:42 GMT
Find Nodes?
    Voting Booth?