← Index
NYTProf Performance Profile   « block view • line view • sub view »
For mentat.storage.mongo.pl
  Run on Tue Jun 24 09:58:41 2014
Reported on Tue Jun 24 09:59:17 2014

Filename/usr/local/share/perl/5.14.2/DateTime/TimeZone/Local/Unix.pm
StatementsExecuted 1757 statements in 37.3ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
16924119.1ms32.0msDateTime::TimeZone::Local::Unix::::__ANON__[:116]DateTime::TimeZone::Local::Unix::__ANON__[:116]
11113.5ms91.6msDateTime::TimeZone::Local::Unix::::_FindMatchingZoneinfoFileDateTime::TimeZone::Local::Unix::_FindMatchingZoneinfoFile
1692117.62ms7.62msDateTime::TimeZone::Local::Unix::::CORE:ftfileDateTime::TimeZone::Local::Unix::CORE:ftfile (opcode)
1116.80ms7.46msDateTime::TimeZone::Local::Unix::::BEGIN@12DateTime::TimeZone::Local::Unix::BEGIN@12
1636214.44ms4.44msDateTime::TimeZone::Local::Unix::::CORE:ftlinkDateTime::TimeZone::Local::Unix::CORE:ftlink (opcode)
79131438µs438µsDateTime::TimeZone::Local::Unix::::CORE:ftsizeDateTime::TimeZone::Local::Unix::CORE:ftsize (opcode)
111140µs110msDateTime::TimeZone::Local::Unix::::FromEtcLocaltimeDateTime::TimeZone::Local::Unix::FromEtcLocaltime
11120µs20µsDateTime::TimeZone::Local::Unix::::BEGIN@5DateTime::TimeZone::Local::Unix::BEGIN@5
11120µs71µsDateTime::TimeZone::Local::Unix::::BEGIN@13DateTime::TimeZone::Local::Unix::BEGIN@13
11116µs23µsDateTime::TimeZone::Local::Unix::::BEGIN@9DateTime::TimeZone::Local::Unix::BEGIN@9
11116µs28µsDateTime::TimeZone::Local::Unix::::BEGIN@10DateTime::TimeZone::Local::Unix::BEGIN@10
1118µs8µsDateTime::TimeZone::Local::Unix::::CORE:ftereadDateTime::TimeZone::Local::Unix::CORE:fteread (opcode)
1115µs5µsDateTime::TimeZone::Local::Unix::::MethodsDateTime::TimeZone::Local::Unix::Methods
1114µs4µsDateTime::TimeZone::Local::Unix::::CORE:ftdirDateTime::TimeZone::Local::Unix::CORE:ftdir (opcode)
1112µs2µsDateTime::TimeZone::Local::Unix::::EnvVarsDateTime::TimeZone::Local::Unix::EnvVars
0000s0sDateTime::TimeZone::Local::Unix::::FromEtcDefaultInitDateTime::TimeZone::Local::Unix::FromEtcDefaultInit
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::::_ReadEtcDefaultInitDateTime::TimeZone::Local::Unix::_ReadEtcDefaultInit
0000s0sDateTime::TimeZone::Local::Unix::::_ReadEtcSysconfigClockDateTime::TimeZone::Local::Unix::_ReadEtcSysconfigClock
0000s0sDateTime::TimeZone::Local::Unix::::_ReadlinkDateTime::TimeZone::Local::Unix::_Readlink
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;
2{
323µs $DateTime::TimeZone::Local::Unix::VERSION = '1.63';
4}
5
# spent 20µs within DateTime::TimeZone::Local::Unix::BEGIN@5 which was called: # once (20µs+0s) by Module::Runtime::require_module at line 7
BEGIN {
6111µs $DateTime::TimeZone::Local::Unix::AUTHORITY = 'cpan:DROLSKY';
7147µs120µs}
# spent 20µs making 1 call to DateTime::TimeZone::Local::Unix::BEGIN@5
8
9265µs230µs
# spent 23µs (16+7) within DateTime::TimeZone::Local::Unix::BEGIN@9 which was called: # once (16µs+7µs) by Module::Runtime::require_module at line 9
use strict;
# spent 23µs making 1 call to DateTime::TimeZone::Local::Unix::BEGIN@9 # spent 7µs making 1 call to strict::import
10256µs241µs
# spent 28µs (16+12) within DateTime::TimeZone::Local::Unix::BEGIN@10 which was called: # once (16µs+12µs) by Module::Runtime::require_module at line 10
use warnings;
# spent 28µs making 1 call to DateTime::TimeZone::Local::Unix::BEGIN@10 # spent 12µs making 1 call to warnings::import
11
123274µs37.58ms
# spent 7.46ms (6.80+660µs) within DateTime::TimeZone::Local::Unix::BEGIN@12 which was called: # once (6.80ms+660µs) by Module::Runtime::require_module at line 12
use Cwd 3;
# spent 7.46ms making 1 call to DateTime::TimeZone::Local::Unix::BEGIN@12 # spent 92µs making 1 call to Exporter::import # spent 28µs making 1 call to UNIVERSAL::VERSION
1322.14ms2122µs
# spent 71µs (20+51) within DateTime::TimeZone::Local::Unix::BEGIN@13 which was called: # once (20µs+51µs) by Module::Runtime::require_module at line 13
use parent 'DateTime::TimeZone::Local';
# spent 71µs making 1 call to DateTime::TimeZone::Local::Unix::BEGIN@13 # spent 51µs making 1 call to parent::import
14
15
# spent 5µs within DateTime::TimeZone::Local::Unix::Methods which was called: # once (5µs+0s) by DateTime::TimeZone::Local::TimeZone at line 21 of DateTime/TimeZone/Local.pm
sub Methods {
1618µs return qw(
17 FromEnv
18 FromEtcLocaltime
19 FromEtcTimezone
20 FromEtcTIMEZONE
21 FromEtcSysconfigClock
22 FromEtcDefaultInit
23 );
24}
25
2616µs
# spent 2µs within DateTime::TimeZone::Local::Unix::EnvVars which was called: # once (2µs+0s) by DateTime::TimeZone::Local::FromEnv at line 67 of DateTime/TimeZone/Local.pm
sub EnvVars { return 'TZ' }
27
28
# spent 110ms (140µs+110) within DateTime::TimeZone::Local::Unix::FromEtcLocaltime which was called: # once (140µs+110ms) by DateTime::TimeZone::Local::TimeZone at line 22 of DateTime/TimeZone/Local.pm
sub FromEtcLocaltime {
29754µs my $class = shift;
30
31 my $lt_file = '/etc/localtime';
32
3329µs return unless -r $lt_file && -s _;
# spent 8µs making 1 call to DateTime::TimeZone::Local::Unix::CORE:fteread # spent 600ns making 1 call to DateTime::TimeZone::Local::Unix::CORE:ftsize
34
35 my $real_name;
3619µs if ( -l $lt_file ) {
# spent 9µ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
42191.6ms $real_name ||= $class->_FindMatchingZoneinfoFile($lt_file);
43
44334µs if ( defined $real_name ) {
45132µs my ( $vol, $dirs, $file ) = File::Spec->splitpath($real_name);
# spent 32µs making 1 call to File::Spec::Unix::splitpath
46
47 my @parts
4873µs16µs = grep { defined && length } File::Spec->splitdir($dirs), $file;
# spent 6µs making 1 call to File::Spec::Unix::splitdir
49
50 foreach my $x ( reverse 0 .. $#parts ) {
51822µs my $name = (
52 $x < $#parts
53 ? join '/', @parts[ $x .. $#parts ]
54 : $parts[$x]
55 );
56
57 my $tz;
58 {
59613µs local $@;
60 local $SIG{__DIE__};
61218µs20s $tz = eval { DateTime::TimeZone->new( name => $name ) };
# spent 18.3ms making 2 calls to DateTime::TimeZone::new, avg 9.17ms/call, recursion: max depth 1, sum of overlapping time 18.3ms
62 }
63
64 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
77# for systems where /etc/localtime is a copy of a zoneinfo file
78
# spent 91.6ms (13.5+78.1) within DateTime::TimeZone::Local::Unix::_FindMatchingZoneinfoFile which was called: # once (13.5ms+78.1ms) by DateTime::TimeZone::Local::Unix::FromEtcLocaltime at line 42
sub _FindMatchingZoneinfoFile {
7913656µs my $class = shift;
80 my $file_to_match = shift;
81
8214µs return unless -d '/usr/share/zoneinfo';
# spent 4µs making 1 call to DateTime::TimeZone::Local::Unix::CORE:ftdir
83
84 require File::Basename;
85 require File::Compare;
86 require File::Find;
87
8818µs my $size = -s $file_to_match;
# spent 8µs making 1 call to DateTime::TimeZone::Local::Unix::CORE:ftsize
89
90 my $real_name;
91 local $@;
92 local $SIG{__DIE__};
93 local $_;
94112µs eval {
95 File::Find::find(
96 {
97
# spent 32.0ms (19.1+12.9) within DateTime::TimeZone::Local::Unix::__ANON__[/usr/local/share/perl/5.14.2/DateTime/TimeZone/Local/Unix.pm:116] which was called 1692 times, avg 19µs/call: # 1082 times (12.3ms+8.75ms) by File::Find::_find_dir at line 749 of File/Find.pm, avg 19µs/call # 475 times (5.51ms+3.31ms) by File::Find::_find_dir at line 781 of File/Find.pm, avg 19µs/call # 78 times (869µs+616µs) by File::Find::_find_dir at line 787 of File/Find.pm, avg 19µs/call # 57 times (406µs+215µs) by File::Find::_find_dir at line 691 of File/Find.pm, avg 11µs/call
wanted => sub {
98169433.8ms411812.9ms if (
# spent 7.62ms making 1692 calls to DateTime::TimeZone::Local::Unix::CORE:ftfile, avg 5µs/call # spent 4.43ms making 1635 calls to DateTime::TimeZone::Local::Unix::CORE:ftlink, avg 3µs/call # spent 429µs making 789 calls to DateTime::TimeZone::Local::Unix::CORE:ftsize, avg 544ns/call # spent 271µs making 1 call to File::Compare::compare # spent 135µs making 1 call to File::Basename::basename
99 !defined $real_name
100 && -f $_
101 && !-l $_
102 && $size == -s _
103
104 # This fixes RT 24026 - apparently such a
105 # file exists on FreeBSD and it can cause a
106 # false positive
107 && File::Basename::basename($_) ne 'posixrules'
108 && File::Compare::compare( $_, $file_to_match ) == 0
109 ) {
110 $real_name = $_;
111
112 # File::Find has no mechanism for bailing in the
113 # middle of a find.
114 die { found => 1 };
115 }
116 },
117174.4ms no_chdir => 1,
# spent 74.4ms making 1 call to File::Find::find
118 },
119 '/usr/share/zoneinfo',
120 );
121 };
122
123117µs if ($@) {
124 return $real_name if ref $@ && $@->{found};
125 die $@;
126 }
127}
128
129sub FromEtcTimezone {
130 my $class = shift;
131
132 my $tz_file = '/etc/timezone';
133
134 return unless -f $tz_file && -r _;
135
136 local *TZ;
137 open TZ, "<$tz_file"
138 or die "Cannot read $tz_file: $!";
139 my $name = join '', <TZ>;
140 close TZ;
141
142 $name =~ s/^\s+|\s+$//g;
143
144 return unless $class->_IsValidName($name);
145
146 local $@;
147 local $SIG{__DIE__};
148 return eval { DateTime::TimeZone->new( name => $name ) };
149}
150
151sub FromEtcTIMEZONE {
152 my $class = shift;
153
154 my $tz_file = '/etc/TIMEZONE';
155
156 return unless -f $tz_file && -r _;
157
158 local *TZ;
159 open TZ, "<$tz_file"
160 or die "Cannot read $tz_file: $!";
161
162 my $name;
163 while ( defined( $name = <TZ> ) ) {
164 if ( $name =~ /\A\s*TZ\s*=\s*(\S+)/ ) {
165 $name = $1;
166 last;
167 }
168 }
169
170 close TZ;
171
172 return unless $class->_IsValidName($name);
173
174 local $@;
175 local $SIG{__DIE__};
176 return eval { DateTime::TimeZone->new( name => $name ) };
177}
178
179# RedHat uses this
180sub FromEtcSysconfigClock {
181 my $class = shift;
182
183 return unless -r "/etc/sysconfig/clock" && -f _;
184
185 my $name = $class->_ReadEtcSysconfigClock();
186
187 return unless $class->_IsValidName($name);
188
189 local $@;
190 local $SIG{__DIE__};
191 return eval { DateTime::TimeZone->new( name => $name ) };
192}
193
194# this is a separate function so that it can be overridden in the test suite
195sub _ReadEtcSysconfigClock {
196 my $class = shift;
197
198 local *CLOCK;
199 open CLOCK, '</etc/sysconfig/clock'
200 or die "Cannot read /etc/sysconfig/clock: $!";
201
202 local $_;
203 while (<CLOCK>) {
204 return $1 if /^(?:TIME)?ZONE="([^"]+)"/;
205 }
206}
207
208sub FromEtcDefaultInit {
209 my $class = shift;
210
211 return unless -r "/etc/default/init" && -f _;
212
213 my $name = $class->_ReadEtcDefaultInit();
214
215 return unless $class->_IsValidName($name);
216
217 local $@;
218 local $SIG{__DIE__};
219 return eval { DateTime::TimeZone->new( name => $name ) };
220}
221
222# this is a separate function so that it can be overridden in the test
223# suite
224sub _ReadEtcDefaultInit {
225 my $class = shift;
226
227 local *INIT;
228 open INIT, '</etc/default/init'
229 or die "Cannot read /etc/default/init: $!";
230
231 local $_;
232 while (<INIT>) {
233 return $1 if /^TZ=(.+)/;
234 }
235}
236
23716µs1;
238
239# ABSTRACT: Determine the local system's time zone on Unix
240
241__END__
 
# spent 4µs within DateTime::TimeZone::Local::Unix::CORE:ftdir which was called: # once (4µs+0s) by DateTime::TimeZone::Local::Unix::_FindMatchingZoneinfoFile at line 82
sub DateTime::TimeZone::Local::Unix::CORE:ftdir; # opcode
# spent 8µs within DateTime::TimeZone::Local::Unix::CORE:fteread which was called: # once (8µs+0s) by DateTime::TimeZone::Local::Unix::FromEtcLocaltime at line 33
sub DateTime::TimeZone::Local::Unix::CORE:fteread; # opcode
# spent 7.62ms within DateTime::TimeZone::Local::Unix::CORE:ftfile which was called 1692 times, avg 5µs/call: # 1692 times (7.62ms+0s) by DateTime::TimeZone::Local::Unix::__ANON__[/usr/local/share/perl/5.14.2/DateTime/TimeZone/Local/Unix.pm:116] at line 98, avg 5µs/call
sub DateTime::TimeZone::Local::Unix::CORE:ftfile; # opcode
# spent 4.44ms within DateTime::TimeZone::Local::Unix::CORE:ftlink which was called 1636 times, avg 3µs/call: # 1635 times (4.43ms+0s) by DateTime::TimeZone::Local::Unix::__ANON__[/usr/local/share/perl/5.14.2/DateTime/TimeZone/Local/Unix.pm:116] at line 98, avg 3µs/call # once (9µs+0s) by DateTime::TimeZone::Local::Unix::FromEtcLocaltime at line 36
sub DateTime::TimeZone::Local::Unix::CORE:ftlink; # opcode
# spent 438µs within DateTime::TimeZone::Local::Unix::CORE:ftsize which was called 791 times, avg 553ns/call: # 789 times (429µs+0s) by DateTime::TimeZone::Local::Unix::__ANON__[/usr/local/share/perl/5.14.2/DateTime/TimeZone/Local/Unix.pm:116] at line 98, avg 544ns/call # once (8µs+0s) by DateTime::TimeZone::Local::Unix::_FindMatchingZoneinfoFile at line 88 # once (600ns+0s) by DateTime::TimeZone::Local::Unix::FromEtcLocaltime at line 33
sub DateTime::TimeZone::Local::Unix::CORE:ftsize; # opcode