in reply to Tied Hashes vs. Objects
From what I recall, tied hashes are measurably, but not horribly so, slower than an equivalently functioning object. I believe there are one or two extra indirections involved in method resolution.
But for that penalty, you get -- as you observed -- transparency for any and all code that need to use the 'special hash'. That is a substantial advantage in terms of developer efficiency and code-base simplicity. Two huge advantages well worth the cost of a few microseconds.
So, unless it is observable that your code is becoming a bottleneck in the overall process, don't even consider it.
If it is observable that your code is becoming a bottleneck, then profile the code -- the entire code, end to end -- and determine if those one or two extra dereferences are actually a substantial contributory factor. In most cases they will not be.
You need to be processing substantial amounts of in-memory data, very intensively, before such small differences become significant.
I have switched from a tied interface to using the method interface enabled by the object handle returned from tie, for performance reasons when performing cpu-intensive processing on huge, in-memory datasets, once or twice in the past. But as I recall, on both occasions I later found other changes that saved much more that the switch did and I reverted. The transparency of tied datasets is just too effective to discard without good reason.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Tied Hashes vs. Objects
by Anonymous Monk on Oct 22, 2012 at 19:14 UTC | |
by BrowserUk (Patriarch) on Oct 22, 2012 at 21:31 UTC | |
by tkemmer (Initiate) on Oct 23, 2012 at 07:03 UTC |