← 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:31:39 2016

Filename/usr/share/perl5/DateTime/TimeZone/Local/Unix.pm
StatementsExecuted 88 statements in 2.12ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
111906µs1.78msDateTime::TimeZone::Local::Unix::::_FindMatchingZoneinfoFileDateTime::TimeZone::Local::Unix::_FindMatchingZoneinfoFile
361141µs41µsDateTime::TimeZone::Local::Unix::::CORE:ftfileDateTime::TimeZone::Local::Unix::CORE:ftfile (opcode)
362131µs31µsDateTime::TimeZone::Local::Unix::::CORE:ftlinkDateTime::TimeZone::Local::Unix::CORE:ftlink (opcode)
11126µs90µsDateTime::TimeZone::Local::Unix::::BEGIN@6DateTime::TimeZone::Local::Unix::BEGIN@6
11120µs32µsDateTime::TimeZone::Local::Unix::::BEGIN@3DateTime::TimeZone::Local::Unix::BEGIN@3
11113µs43µsDateTime::TimeZone::Local::Unix::::BEGIN@7DateTime::TimeZone::Local::Unix::BEGIN@7
11111µs21µsDateTime::TimeZone::Local::Unix::::BEGIN@4DateTime::TimeZone::Local::Unix::BEGIN@4
1119µs30µsDateTime::TimeZone::Local::Unix::::_EtcFileDateTime::TimeZone::Local::Unix::_EtcFile
30318µs8µ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;
21500ns$DateTime::TimeZone::Local::Unix::VERSION = '1.75';
3248µs244µs
# spent 32µs (20+12) within DateTime::TimeZone::Local::Unix::BEGIN@3 which was called: # once (20µs+12µs) by C4::NewsChannels::GetNewsToDisplay at line 3
use strict;
# spent 32µs making 1 call to DateTime::TimeZone::Local::Unix::BEGIN@3 # spent 12µs making 1 call to strict::import
4245µs232µs
# spent 21µs (11+10) within DateTime::TimeZone::Local::Unix::BEGIN@4 which was called: # once (11µs+10µs) by C4::NewsChannels::GetNewsToDisplay at line 4
use warnings;
# spent 21µs making 1 call to DateTime::TimeZone::Local::Unix::BEGIN@4 # spent 10µs making 1 call to warnings::import
5
63117µs3153µs
# spent 90µs (26+64) within DateTime::TimeZone::Local::Unix::BEGIN@6 which was called: # once (26µs+64µs) by C4::NewsChannels::GetNewsToDisplay at line 6
use Cwd 3;
# spent 90µs making 1 call to DateTime::TimeZone::Local::Unix::BEGIN@6 # spent 46µs making 1 call to Exporter::import # spent 18µs making 1 call to version::vxs::_VERSION
721.22ms272µs
# spent 43µs (13+30) within DateTime::TimeZone::Local::Unix::BEGIN@7 which was called: # once (13µs+30µs) by C4::NewsChannels::GetNewsToDisplay at line 7
use parent 'DateTime::TimeZone::Local';
# spent 43µs making 1 call to DateTime::TimeZone::Local::Unix::BEGIN@7 # spent 30µs making 1 call to parent::import
8
9sub Methods {
101600ns return qw(
11 FromEnv
12 FromEtcLocaltime
13 FromEtcTimezone
14 FromEtcTIMEZONE
15 FromEtcSysconfigClock
16 FromEtcDefaultInit
17 );
18}
19
201300nssub EnvVars { return 'TZ' }
21
221100nsour $EtcDir = '/etc';
23
24
# spent 30µs (9+21) within DateTime::TimeZone::Local::Unix::_EtcFile which was called: # once (9µs+21µs) by C4::NewsChannels::GetNewsToDisplay at line 32
sub _EtcFile {
251100ns shift;
26132µs430µs return File::Spec->catfile( $EtcDir, @_ );
# spent 21µs making 1 call to File::Spec::Unix::catfile # spent 7µs making 1 call to File::Spec::Unix::catdir # spent 2µs making 2 calls to File::Spec::Unix::canonpath, avg 1µs/call
27}
28
29sub FromEtcLocaltime {
301300ns my $class = shift;
31
3212µs130µs my $lt_file = $class->_EtcFile('localtime');
# spent 30µs making 1 call to DateTime::TimeZone::Local::Unix::_EtcFile
33120µs28µs return unless -r $lt_file && -s _;
# spent 7µs making 1 call to DateTime::TimeZone::Local::Unix::CORE:fteread # spent 700ns making 1 call to DateTime::TimeZone::Local::Unix::CORE:ftsize
34
351100ns my $real_name;
3616µs12µs if ( -l $lt_file ) {
# spent 2µ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.78ms $real_name ||= $class->_FindMatchingZoneinfoFile($lt_file);
43
441300ns if ( defined $real_name ) {
45118µs110µs my ( $vol, $dirs, $file ) = File::Spec->splitpath($real_name);
# spent 10µs making 1 call to File::Spec::Unix::splitpath
46
47 my @parts
48110µs14µs = grep { defined && length } File::Spec->splitdir($dirs), $file;
# spent 4µs making 1 call to File::Spec::Unix::splitdir
49
5011µs foreach my $x ( reverse 0 .. $#parts ) {
511700ns my $name = (
52 $x < $#parts
53 ? join '/', @parts[ $x .. $#parts ]
54 : $parts[$x]
55 );
56
571100ns my $tz;
58 {
592500ns local $@;
6012µs local $SIG{__DIE__};
61269µs10s $tz = eval { DateTime::TimeZone->new( name => $name ) };
# spent 58µs making 1 call to DateTime::TimeZone::new, recursion: max depth 1, sum of overlapping time 58µs
62 }
63
6417µ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
771100nsour $ZoneinfoDir = '/usr/share/zoneinfo';
78# for systems where /etc/localtime is a copy of a zoneinfo file
79
# spent 1.78ms (906µs+874µs) within DateTime::TimeZone::Local::Unix::_FindMatchingZoneinfoFile which was called: # once (906µs+874µs) by C4::NewsChannels::GetNewsToDisplay at line 42
sub _FindMatchingZoneinfoFile {
801300ns my $class = shift;
811100ns my $file_to_match = shift;
82
8317µs12µs return unless -d $ZoneinfoDir;
# spent 2µs making 1 call to DateTime::TimeZone::Local::Unix::CORE:ftdir
84
8511µs require File::Basename;
861136µs require File::Compare;
871500ns require File::Find;
88
8919µs14µs my $size = -s $file_to_match;
# spent 4µs making 1 call to DateTime::TimeZone::Local::Unix::CORE:ftsize
90
911100ns my $real_name;
921400ns local $@;
9312µs local $SIG{__DIE__};
941100ns local $_;
951300ns eval {
96 File::Find::find(
97 {
98 wanted => sub {
9936273µs103286µs if (
# spent 157µs making 2 calls to File::Compare::compare, avg 78µs/call # spent 56µs making 2 calls to File::Basename::basename, avg 28µs/call # spent 41µs making 36 calls to DateTime::TimeZone::Local::Unix::CORE:ftfile, avg 1µs/call # spent 29µs making 35 calls to DateTime::TimeZone::Local::Unix::CORE:ftlink, avg 826ns/call # spent 3µs making 28 calls to DateTime::TimeZone::Local::Unix::CORE:ftsize, avg 114ns/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 ) {
1111300ns $real_name = $_;
112
113 # File::Find has no mechanism for bailing in the
114 # middle of a find.
115121µs die { found => 1 };
116 }
117 },
118154µs1809µs no_chdir => 1,
# spent 809µs making 1 call to File::Find::find
119 },
120 $ZoneinfoDir,
121 );
122 };
123
1241400ns if ($@) {
12517µ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
23614µ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 41µs within DateTime::TimeZone::Local::Unix::CORE:ftfile which was called 36 times, avg 1µs/call: # 36 times (41µs+0s) by File::Find::find at line 99, avg 1µs/call
sub DateTime::TimeZone::Local::Unix::CORE:ftfile; # opcode
# spent 31µs within DateTime::TimeZone::Local::Unix::CORE:ftlink which was called 36 times, avg 872ns/call: # 35 times (29µs+0s) by File::Find::find at line 99, avg 826ns/call # once (2µs+0s) by C4::NewsChannels::GetNewsToDisplay at line 36
sub DateTime::TimeZone::Local::Unix::CORE:ftlink; # opcode
# spent 8µs within DateTime::TimeZone::Local::Unix::CORE:ftsize which was called 30 times, avg 257ns/call: # 28 times (3µs+0s) by File::Find::find at line 99, avg 114ns/call # once (4µs+0s) by DateTime::TimeZone::Local::Unix::_FindMatchingZoneinfoFile at line 89 # once (700ns+0s) by C4::NewsChannels::GetNewsToDisplay at line 33
sub DateTime::TimeZone::Local::Unix::CORE:ftsize; # opcode