← Index
NYTProf Performance Profile   « line view »
For starman worker -M FindBin --max-requests 50 --workers 2 --user=kohadev-koha --group kohadev-koha --pid /var/run/koha/kohadev/plack.pid --daemonize --access-log /var/log/koha/kohadev/plack.log --error-log /var/log/koha/kohadev/plack-error.log -E deployment --socket /var/run/koha/kohadev/plack.sock /etc/koha/sites/kohadev/plack.psgi
  Run on Fri Jan 8 14:31:06 2016
Reported on Fri Jan 8 14:33:30 2016

Filename/usr/share/perl5/DateTime/TimeZone/Local/Unix.pm
StatementsExecuted 88 statements in 2.48ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1111.00ms1.97msDateTime::TimeZone::Local::Unix::::_FindMatchingZoneinfoFileDateTime::TimeZone::Local::Unix::_FindMatchingZoneinfoFile
361143µs43µsDateTime::TimeZone::Local::Unix::::CORE:ftfileDateTime::TimeZone::Local::Unix::CORE:ftfile (opcode)
362141µs41µsDateTime::TimeZone::Local::Unix::::CORE:ftlinkDateTime::TimeZone::Local::Unix::CORE:ftlink (opcode)
11135µs96µsDateTime::TimeZone::Local::Unix::::BEGIN@6DateTime::TimeZone::Local::Unix::BEGIN@6
11126µs39µsDateTime::TimeZone::Local::Unix::::BEGIN@3DateTime::TimeZone::Local::Unix::BEGIN@3
11114µs24µsDateTime::TimeZone::Local::Unix::::BEGIN@4DateTime::TimeZone::Local::Unix::BEGIN@4
11112µs40µsDateTime::TimeZone::Local::Unix::::_EtcFileDateTime::TimeZone::Local::Unix::_EtcFile
11111µs45µsDateTime::TimeZone::Local::Unix::::BEGIN@7DateTime::TimeZone::Local::Unix::BEGIN@7
303111µs11µsDateTime::TimeZone::Local::Unix::::CORE:ftsizeDateTime::TimeZone::Local::Unix::CORE:ftsize (opcode)
1117µs7µsDateTime::TimeZone::Local::Unix::::CORE:ftereadDateTime::TimeZone::Local::Unix::CORE:fteread (opcode)
1112µs2µsDateTime::TimeZone::Local::Unix::::CORE:ftdirDateTime::TimeZone::Local::Unix::CORE:ftdir (opcode)
0000s0sDateTime::TimeZone::Local::Unix::::EnvVarsDateTime::TimeZone::Local::Unix::EnvVars
0000s0sDateTime::TimeZone::Local::Unix::::FromEtcDefaultInitDateTime::TimeZone::Local::Unix::FromEtcDefaultInit
0000s0sDateTime::TimeZone::Local::Unix::::FromEtcLocaltimeDateTime::TimeZone::Local::Unix::FromEtcLocaltime
0000s0sDateTime::TimeZone::Local::Unix::::FromEtcSysconfigClockDateTime::TimeZone::Local::Unix::FromEtcSysconfigClock
0000s0sDateTime::TimeZone::Local::Unix::::FromEtcTIMEZONEDateTime::TimeZone::Local::Unix::FromEtcTIMEZONE
0000s0sDateTime::TimeZone::Local::Unix::::FromEtcTimezoneDateTime::TimeZone::Local::Unix::FromEtcTimezone
0000s0sDateTime::TimeZone::Local::Unix::::MethodsDateTime::TimeZone::Local::Unix::Methods
0000s0sDateTime::TimeZone::Local::Unix::::_ReadEtcDefaultInitDateTime::TimeZone::Local::Unix::_ReadEtcDefaultInit
0000s0sDateTime::TimeZone::Local::Unix::::_ReadEtcSysconfigClockDateTime::TimeZone::Local::Unix::_ReadEtcSysconfigClock
0000s0sDateTime::TimeZone::Local::Unix::::_ReadlinkDateTime::TimeZone::Local::Unix::_Readlink
0000s0sDateTime::TimeZone::Local::Unix::::__ANON__[:117]DateTime::TimeZone::Local::Unix::__ANON__[:117]
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package DateTime::TimeZone::Local::Unix;
2115µs$DateTime::TimeZone::Local::Unix::VERSION = '1.75';
3254µs251µs
# spent 39µs (26+12) within DateTime::TimeZone::Local::Unix::BEGIN@3 which was called: # once (26µs+12µs) by C4::NewsChannels::GetNewsToDisplay at line 3
use strict;
# spent 39µs making 1 call to DateTime::TimeZone::Local::Unix::BEGIN@3 # spent 12µs making 1 call to strict::import
4252µs233µs
# spent 24µs (14+10) within DateTime::TimeZone::Local::Unix::BEGIN@4 which was called: # once (14µs+10µs) by C4::NewsChannels::GetNewsToDisplay at line 4
use warnings;
# spent 24µs making 1 call to DateTime::TimeZone::Local::Unix::BEGIN@4 # spent 10µs making 1 call to warnings::import
5
63122µs3158µs
# spent 96µs (35+62) within DateTime::TimeZone::Local::Unix::BEGIN@6 which was called: # once (35µs+62µs) by C4::NewsChannels::GetNewsToDisplay at line 6
use Cwd 3;
# spent 96µs making 1 call to DateTime::TimeZone::Local::Unix::BEGIN@6 # spent 46µs making 1 call to Exporter::import # spent 16µs making 1 call to version::vxs::_VERSION
72679µs280µs
# spent 45µs (11+34) within DateTime::TimeZone::Local::Unix::BEGIN@7 which was called: # once (11µs+34µs) by C4::NewsChannels::GetNewsToDisplay at line 7
use parent 'DateTime::TimeZone::Local';
# spent 45µs making 1 call to DateTime::TimeZone::Local::Unix::BEGIN@7 # spent 34µs making 1 call to parent::import
8
9sub Methods {
1019µs return qw(
11 FromEnv
12 FromEtcLocaltime
13 FromEtcTimezone
14 FromEtcTIMEZONE
15 FromEtcSysconfigClock
16 FromEtcDefaultInit
17 );
18}
19
2014µssub EnvVars { return 'TZ' }
21
221701µsour $EtcDir = '/etc';
23
24
# spent 40µs (12+27) within DateTime::TimeZone::Local::Unix::_EtcFile which was called: # once (12µs+27µs) by C4::NewsChannels::GetNewsToDisplay at line 32
sub _EtcFile {
2511µs shift;
26138µs437µs return File::Spec->catfile( $EtcDir, @_ );
# spent 27µs making 1 call to File::Spec::Unix::catfile # spent 7µs making 1 call to File::Spec::Unix::catdir # spent 3µs making 2 calls to File::Spec::Unix::canonpath, avg 1µs/call
27}
28
29sub FromEtcLocaltime {
3012µs my $class = shift;
31
3216µs140µs my $lt_file = $class->_EtcFile('localtime');
# spent 40µs making 1 call to DateTime::TimeZone::Local::Unix::_EtcFile
33120µs29µs return unless -r $lt_file && -s _;
# spent 7µs making 1 call to DateTime::TimeZone::Local::Unix::CORE:fteread # spent 2µs making 1 call to DateTime::TimeZone::Local::Unix::CORE:ftsize
34
351100ns my $real_name;
3616µs13µs if ( -l $lt_file ) {
# spent 3µs making 1 call to DateTime::TimeZone::Local::Unix::CORE:ftlink
37
38 # The _Readlink sub exists so the test suite can mock it.
39 $real_name = $class->_Readlink($lt_file);
40 }
41
4212µs11.97ms $real_name ||= $class->_FindMatchingZoneinfoFile($lt_file);
43
441500ns if ( defined $real_name ) {
45120µs111µs my ( $vol, $dirs, $file ) = File::Spec->splitpath($real_name);
# spent 11µs making 1 call to File::Spec::Unix::splitpath
46
47 my @parts
48112µs14µs = grep { defined && length } File::Spec->splitdir($dirs), $file;
# spent 4µs making 1 call to File::Spec::Unix::splitdir
49
5012µs foreach my $x ( reverse 0 .. $#parts ) {
5111µs my $name = (
52 $x < $#parts
53 ? join '/', @parts[ $x .. $#parts ]
54 : $parts[$x]
55 );
56
571200ns my $tz;
58 {
592500ns local $@;
6012µs local $SIG{__DIE__};
61282µs10s $tz = eval { DateTime::TimeZone->new( name => $name ) };
# spent 68µs making 1 call to DateTime::TimeZone::new, recursion: max depth 1, sum of overlapping time 68µs
62 }
63
6418µs return $tz if $tz;
65 }
66 }
67}
68
69sub _Readlink {
70 my $link = $_[1];
71
72 # Using abs_path will resolve multiple levels of link indirection,
73 # whereas readlink just follows the link to the next target.
74 return Cwd::abs_path($link);
75}
76
77124µsour $ZoneinfoDir = '/usr/share/zoneinfo';
78# for systems where /etc/localtime is a copy of a zoneinfo file
79
# spent 1.97ms (1.00+970µs) within DateTime::TimeZone::Local::Unix::_FindMatchingZoneinfoFile which was called: # once (1.00ms+970µs) by C4::NewsChannels::GetNewsToDisplay at line 42
sub _FindMatchingZoneinfoFile {
801400ns my $class = shift;
811200ns my $file_to_match = shift;
82
8318µs12µs return unless -d $ZoneinfoDir;
# spent 2µs making 1 call to DateTime::TimeZone::Local::Unix::CORE:ftdir
84
8512µs require File::Basename;
861135µs require File::Compare;
871800ns require File::Find;
88
89112µs16µs my $size = -s $file_to_match;
# spent 6µs making 1 call to DateTime::TimeZone::Local::Unix::CORE:ftsize
90
911100ns my $real_name;
921300ns local $@;
9312µs local $SIG{__DIE__};
941300ns local $_;
951500ns eval {
96 File::Find::find(
97 {
98 wanted => sub {
9936314µs103317µs if (
# spent 170µs making 2 calls to File::Compare::compare, avg 85µs/call # spent 62µs making 2 calls to File::Basename::basename, avg 31µs/call # spent 43µs making 36 calls to DateTime::TimeZone::Local::Unix::CORE:ftfile, avg 1µs/call # spent 38µs making 35 calls to DateTime::TimeZone::Local::Unix::CORE:ftlink, avg 1µs/call # spent 3µs making 28 calls to DateTime::TimeZone::Local::Unix::CORE:ftsize, avg 121ns/call
100 !defined $real_name
101 && -f $_
102 && !-l $_
103 && $size == -s _
104
105 # This fixes RT 24026 - apparently such a
106 # file exists on FreeBSD and it can cause a
107 # false positive
108 && File::Basename::basename($_) ne 'posixrules'
109 && File::Compare::compare( $_, $file_to_match ) == 0
110 ) {
1111400ns $real_name = $_;
112
113 # File::Find has no mechanism for bailing in the
114 # middle of a find.
115126µs die { found => 1 };
116 }
117 },
118185µs1898µs no_chdir => 1,
# spent 898µs making 1 call to File::Find::find
119 },
120 $ZoneinfoDir,
121 );
122 };
123
1241400ns if ($@) {
12519µs return $real_name if ref $@ && $@->{found};
126 die $@;
127 }
128}
129
130sub FromEtcTimezone {
131 my $class = shift;
132
133 my $tz_file = $class->_EtcFile('timezone');
134 return unless -f $tz_file && -r _;
135
136 open my $fh, '<', $tz_file
137 or die "Cannot read $tz_file: $!";
138 my $name = join '', <$fh>;
139 close $fh;
140
141 $name =~ s/^\s+|\s+$//g;
142
143 return unless $class->_IsValidName($name);
144
145 local $@;
146 local $SIG{__DIE__};
147 return eval { DateTime::TimeZone->new( name => $name ) };
148}
149
150sub FromEtcTIMEZONE {
151 my $class = shift;
152
153 my $tz_file = $class->_EtcFile('TIMEZONE');
154 return unless -f $tz_file && -r _;
155
156 open my $fh, '<', $tz_file
157 or die "Cannot read $tz_file: $!";
158
159 my $name;
160 while ( defined( $name = <$fh> ) ) {
161 if ( $name =~ /\A\s*TZ\s*=\s*(\S+)/ ) {
162 $name = $1;
163 last;
164 }
165 }
166
167 close $fh;
168
169 return unless $class->_IsValidName($name);
170
171 local $@;
172 local $SIG{__DIE__};
173 return eval { DateTime::TimeZone->new( name => $name ) };
174}
175
176# RedHat uses this
177sub FromEtcSysconfigClock {
178 my $class = shift;
179
180 my $clock_file = $class->_EtcFile('sysconfig/clock');
181 return unless -r $clock_file && -f _;
182
183 my $name = $class->_ReadEtcSysconfigClock($clock_file);
184
185 return unless $class->_IsValidName($name);
186
187 local $@;
188 local $SIG{__DIE__};
189 return eval { DateTime::TimeZone->new( name => $name ) };
190}
191
192# this is a separate function so that it can be overridden in the test suite
193sub _ReadEtcSysconfigClock {
194 my $class = shift;
195 my $clock_file = shift;
196
197 open my $fh, '<', $clock_file
198 or die "Cannot read $clock_file: $!";
199
200 local $_;
201 while (<$fh>) {
202 return $1 if /^(?:TIME)?ZONE="([^"]+)"/;
203 }
204}
205
206sub FromEtcDefaultInit {
207 my $class = shift;
208
209 my $init_file = $class->_EtcFile('default/init');
210 return unless -r $init_file && -f _;
211
212 my $name = $class->_ReadEtcDefaultInit($init_file);
213
214 return unless $class->_IsValidName($name);
215
216 local $@;
217 local $SIG{__DIE__};
218 return eval { DateTime::TimeZone->new( name => $name ) };
219}
220
221# this is a separate function so that it can be overridden in the test
222# suite
223sub _ReadEtcDefaultInit {
224 my $class = shift;
225 my $init_file = shift;
226
227 open my $fh, '<', $init_file
228 or die "Cannot read $init_file: $!";
229
230 local $_;
231 while (<$fh>) {
232 return $1 if /^TZ=(.+)/;
233 }
234}
235
236122µs1;
237
238# ABSTRACT: Determine the local system's time zone on Unix
239
240__END__
 
# spent 2µs within DateTime::TimeZone::Local::Unix::CORE:ftdir which was called: # once (2µs+0s) by DateTime::TimeZone::Local::Unix::_FindMatchingZoneinfoFile at line 83
sub DateTime::TimeZone::Local::Unix::CORE:ftdir; # opcode
# spent 7µs within DateTime::TimeZone::Local::Unix::CORE:fteread which was called: # once (7µs+0s) by C4::NewsChannels::GetNewsToDisplay at line 33
sub DateTime::TimeZone::Local::Unix::CORE:fteread; # opcode
# spent 43µs within DateTime::TimeZone::Local::Unix::CORE:ftfile which was called 36 times, avg 1µs/call: # 36 times (43µs+0s) by File::Find::find at line 99, avg 1µs/call
sub DateTime::TimeZone::Local::Unix::CORE:ftfile; # opcode
# spent 41µs within DateTime::TimeZone::Local::Unix::CORE:ftlink which was called 36 times, avg 1µs/call: # 35 times (38µs+0s) by File::Find::find at line 99, avg 1µs/call # once (3µs+0s) by C4::NewsChannels::GetNewsToDisplay at line 36
sub DateTime::TimeZone::Local::Unix::CORE:ftlink; # opcode
# spent 11µs within DateTime::TimeZone::Local::Unix::CORE:ftsize which was called 30 times, avg 377ns/call: # 28 times (3µs+0s) by File::Find::find at line 99, avg 121ns/call # once (6µs+0s) by DateTime::TimeZone::Local::Unix::_FindMatchingZoneinfoFile at line 89 # once (2µs+0s) by C4::NewsChannels::GetNewsToDisplay at line 33
sub DateTime::TimeZone::Local::Unix::CORE:ftsize; # opcode