#!/usr/bin/perl # We dont want to profile strict, so place the autoprofiler # line after that module. use strict; use Devel::AutoProfiler; for ( 1 .. 20 ) { &read_file('/etc/passwd'); } sub read_file { my $file = shift(); open(IN, "$file") || die "Cant access $file\nReason: $!\n"; while () { print "$_"; } close(IN); return; } # Added comments to profiler output and apologies if people # dont like the overuse of # signs # OUTPUT BELOW again without actuall code output # $VAR1 = [ # # The subroutine name called # 'main::read_file', { # # file and line in codebase that routine was called from, # I did this via STDIN, so file is a -, and the call was on # line 6 # 'file -, line 6' => '20', # # number of times the routine was called # 'total_calls' => '20', # # the total time it spent in this particular sub #(in seconds) # 'total_time_in_sub' => '0.090052' } ];