my $start_time = [Time::HiRes::gettimeofday()];
my $diff = Time::HiRes::tv_interval($start_time);
print \"\\n\\n$diff\\n\";
This is useful for in-service timings, granularity of one second:
At start...
$debugtimer = time;
$debugstr = "";
...anywhere and everywhere you like...
kerchunk("message") # message is short description of location in code
...end of program...
print "timings: $debugstr";
...and with your subs:
sub kerchunk
{
my ($msg) = shift;
my $pertock = time;
my $kch = abs($debugtimer - $pertock);
$debugstr .= "Elapsed at $msg: $kch
\n";
}