use Benchmark; # at the beginning: my $benchmarkStart = Benchmark->new(); # code to benchmark # at the end: my $benchmarkEnd = Benchmark->new(); my $diff = Benchmark::timediff($benchmarkEnd, $benchmarkStart); my $str = Benchmark::timestr($diff); if ($str =~ /(\d+)\s*wallclock secs \(\s*?(\d*?\.\d*?)\s*usr\s*\+\s*(\ +d*?\.\d*?)\s/i) { printf ("Execution time: ~ %.0f seconds\nCPU-Time : %.2f\n", +$1, $2); }
Best regards,
perl -e "s>>*F>e=>y)\*martinF)stronat)=>print,print v8.8.8.32.11.32"
In reply to Re: Perl code timing
by strat
in thread Perl code timing
by mcogan1966
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |