Perl – Code Execution Time with accuracy – Time::HiRes



How long does it take to execute some code?

 

use Time::HiRes qw( time );
my $start = time();

// Code goes here

sleep 10;

my $end = time();
print “SPRINTF: “; printf(“%.6f\n”, $end – $start);