use Benchmark to time a loop : Benchmark « System Functions « Perl






use Benchmark to time a loop

   

use Benchmark;

$timestamp1 = new Benchmark;

for ($loop_index = 0; $loop_index < 1_000_000; $loop_index++) {
    $variable1 = 1;
}

$timestamp2 = new Benchmark;
$timedifference = timediff($timestamp2, $timestamp1);

print "The loop took", timestr($timedifference);

   
    
    
  








Related examples in the same category

1.Benchmark timethis