0

Hi, i have 2 pieces of code that i created, both of which do exactly the same thing and i am trying to benchmark them to see which is generally more efficient. As such i used the code suggested by perldoc in the following format:

use Benchmark;
$t0 = Benchmark->new;
# ... your code here ...
$t1 = Benchmark->new;
$td = timediff($t1, $t0);
print "the code took:",timestr($td),"\n";

However both of my code samples are really short and as such come up with a result of "0 wallclock secs ( 0.00 usr + 0.00 sys = 0.00 CPU)"

The fact that both codes run fast is great and all, but both codes use completely different methods, and for the sake of future programming projects, i would like to know which code is functioning more efficiently than the other.

So what i am asking is, how do i benchmark code to fractions of a second?

Thanks for any help.

1
Contributor
1
Reply
13
Views
3 Years
Discussion Span
Last Post by anglaissam
0

nvm, i missed the part where i needed to loop the code for more acurate info.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.