[Chicago-talk] appending hashes

Jay Strauss me at heyjay.com
Tue Nov 4 10:36:30 CST 2003


I did the same thing (figuring it would be faster than the slice)

Jay
----- Original Message ----- 
From: <Andy_Bach at wiwb.uscourts.gov>
To: "Chicago.pm chatter" <chicago-talk at mail.pm.org>
Sent: Tuesday, November 04, 2003 9:51 AM
Subject: Re: [Chicago-talk] appending hashes


> Interestingly (???) the map method:
>  'mapappend' => sub
>          {
>                  %a = %b;
>                  %a = map {$_ => $c{$_} }  keys(%c);
>          },
>
> is slower and gets worse as the hashes get bigger. I bumped up c to:
> %c = map(($_, $_), 0 .. 6750);
> and:
> Benchmark: timing 1000 iterations of append, baseline, mapappend...
>     append: 36 wallclock secs (33.94 usr +  0.22 sys = 34.16 CPU) @
> 29.27/s (n=1000)
>   baseline:  2 wallclock secs ( 2.08 usr +  0.02 sys =  2.10 CPU) @
> 476.19/s (n=1000)
>  mapappend: 65 wallclock secs (61.32 usr +  0.58 sys = 61.90 CPU) @
> 16.16/s (n=1000)
>
> (left off unroll as it was really slow).  Looks like slices are the way to
> go.
>
> a
>
> Andy Bach, Sys. Mangler
> Internet: andy_bach at wiwb.uscourts.gov
> VOICE: (608) 261-5738  FAX 264-5030
>
>
>  "I'm not sure what LInux-friendly means"
> Martin Taylor, MicroSoft's Linux strategist
> _______________________________________________
> 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