[Israel.pm] Rounding benchmark

Gabor Szabo gabor at pti.co.il
Fri May 7 00:03:19 PDT 2004

On Thu, 6 May 2004, Jason Elbaum wrote:

> A simple benchmark of rounding to two decimal places. The code compares
> the mathematical solution with the sprintf solution by generating an
> array of random numbers, rounding them to two decimal places, and
> summing them.
> My results in seconds (YMMV):
>              math    1.79
>              text    4.14
> The sprintf() solution is over twice as slow on my system.


> sub timeit {
>    my ($subname, $routine, $result) = @_;

A side question:

Why are you rolling your own benchmariking function instead of using Benchmark ?


More information about the Perl mailing list