[Chicago-talk] appending hashes

Steven Lembark lembark at jeeves.wrkhors.com
Tue Nov 4 07:37:42 CST 2003



--On Tuesday, November 04, 2003 00:47:16 -0600 Jay Strauss <me at heyjay.com> 
wrote:

> What's the baseline showing?  Just how long it takes to copy a hash?


>> katzung at moon [1057] perl hashtest
>> Benchmark: timing 1000 iterations of append, baseline, unroll...
>>      append:  9 wallclock secs ( 8.56 usr +  0.00 sys =  8.56 CPU) @
>> 116.82/s (n=1000)
>>    baseline:  5 wallclock secs ( 4.57 usr +  0.00 sys =  4.57 CPU) @
>> 218.82/s (n=1000)
>>      unroll: 24 wallclock secs (22.42 usr +  0.00 sys = 22.42 CPU) @
>> 44.60/s (n=1000)

Baseline shows what it takes to copy the same amount of space, append
the time to merge a new set of keys/values into an existing space,
unroll the time to unroll both hashes into lists and re-assign the
result to an existing hash.

If you are doing the job once only to copy 3-5 items at the start of
a program then all of this is moot. If you are making the copy in a
[possibly tight] loop then append is your friend (so to speak).

-- 
Steven Lembark                                            2930 W. Palmer
Workhorse Computing                                    Chicago, IL 60647
                                                         +1 888 910 1206



More information about the Chicago-talk mailing list