[Chicago-talk] appending hashes

Jay Strauss me at heyjay.com
Tue Nov 4 00:47:16 CST 2003


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

Jay
----- Original Message ----- 
From: "Brian Katzung" <briank at kappacs.com>
To: "Chicago.pm chatter" <chicago-talk at mail.pm.org>
Sent: Monday, November 03, 2003 10:06 PM
Subject: Re: [Chicago-talk] appending hashes


> katzung at moon [1056] cat hashtest
> use Benchmark;
> 
> %b = map(($_, $_), 'AA' .. 'ZZ');
> %c = map(($_, $_), 0 .. 675);
> 
> timethese(1000,
> {
>          'baseline' => sub
>          {
>                  %a = %b;
>          },
>          'unroll' => sub
>          {
>                  %a = %b;
>                  %a = (%a, %c);
>          },
>          'append' => sub
>          {
>                  %a = %b;
>                  @a{keys(%c)} = values(%c);
>          }
> }
> );
> 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)
> 
> YMMV
> 
>    - Brian
> 
> 
> _______________________________________________
> Chicago-talk mailing list
> Chicago-talk at mail.pm.org
> http://mail.pm.org/mailman/listinfo/chicago-talk
> 
> 




More information about the Chicago-talk mailing list