Nigel Peck nigel.peck at miswebdesign.com
Mon Mar 2 22:02:04 GMT 2009

Andy Armstrong wrote:
> $ perl bm-foolish-idea.pl
>                        Rate    empty_foreach empty_if_foreach
> empty_foreach     5242880/s               --             -74%
> empty_if_foreach 20309304/s             287%               --
>                           Rate non_empty_if_foreach    non_empty_foreach
> non_empty_if_foreach 1203020/s                   --                 -17%
> non_empty_foreach    1456355/s                  21%                   --

Thanks for this, I've not done any benchmarking before. So if I read 
this right, the "if" version is a lot faster for empty lists, but slows 
it down a bit for non-empty lists?

Sorry for the noob questions, but if these are being compared against 
each other, why are the percentages different?

Feel free to tell me to go and RTFM! :)


More information about the london.pm mailing list