#!/usr/bin/perl use strict; use warnings; use Data::Dumper; use feature 'say'; use Time::HiRes qw(gettimeofday tv_interval); # measure elapsed time say 'Start counting'; my $t0 = [gettimeofday]; # do bunch of stuff here say 'I am doing my things here that I want to know the process time...'; my $t1 = [gettimeofday]; say 'Finished counting'; print Dumper $t0; print Dumper $t1; my $t0_t1 = tv_interval $t0, $t1; say $t0_t1; my $elapsed = tv_interval ($t0, [gettimeofday]); say $elapsed; # $elapsed = tv_interval ($t0); # equivalent code __END__ $ perl test.pl Start counting I am doing my things here that I want to know the process time... Finished counting $VAR1 = [ 1507287063, 951261 ]; $VAR1 = [ 1507287063, 951274 ]; 1.3e-05 8.6e-05