← Index
NYTProf Performance Profile   « block view • line view • sub view »
For mentat.storage.mongo.pl
  Run on Tue Jun 24 10:04:38 2014
Reported on Tue Jun 24 10:05:12 2014

Filename/usr/local/share/perl/5.14.2/DateTime/TimeZone/Local/Unix.pm
StatementsExecuted 1757 statements in 19.3ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1692418.71ms17.0msDateTime::TimeZone::Local::Unix::::__ANON__[:116]DateTime::TimeZone::Local::Unix::__ANON__[:116]
1116.11ms44.4msDateTime::TimeZone::Local::Unix::::_FindMatchingZoneinfoFileDateTime::TimeZone::Local::Unix::_FindMatchingZoneinfoFile
1692115.19ms5.19msDateTime::TimeZone::Local::Unix::::CORE:ftfileDateTime::TimeZone::Local::Unix::CORE:ftfile (opcode)
1113.03ms3.33msDateTime::TimeZone::Local::Unix::::BEGIN@12DateTime::TimeZone::Local::Unix::BEGIN@12
1636212.68ms2.68msDateTime::TimeZone::Local::Unix::::CORE:ftlinkDateTime::TimeZone::Local::Unix::CORE:ftlink (opcode)
79131200µs200µsDateTime::TimeZone::Local::Unix::::CORE:ftsizeDateTime::TimeZone::Local::Unix::CORE:ftsize (opcode)
11162µs52.7msDateTime::TimeZone::Local::Unix::::FromEtcLocaltimeDateTime::TimeZone::Local::Unix::FromEtcLocaltime
1119µs9µsDateTime::TimeZone::Local::Unix::::BEGIN@5DateTime::TimeZone::Local::Unix::BEGIN@5
1119µs31µsDateTime::TimeZone::Local::Unix::::BEGIN@13DateTime::TimeZone::Local::Unix::BEGIN@13
1117µs10µsDateTime::TimeZone::Local::Unix::::BEGIN@9DateTime::TimeZone::Local::Unix::BEGIN@9
1117µs12µsDateTime::TimeZone::Local::Unix::::BEGIN@10DateTime::TimeZone::Local::Unix::BEGIN@10
1116µs6µsDateTime::TimeZone::Local::Unix::::CORE:ftereadDateTime::TimeZone::Local::Unix::CORE:fteread (opcode)
1113µs3µsDateTime::TimeZone::Local::Unix::::CORE:ftdirDateTime::TimeZone::Local::Unix::CORE:ftdir (opcode)
1112µs2µsDateTime::TimeZone::Local::Unix::::MethodsDateTime::TimeZone::Local::Unix::Methods
111800ns800nsDateTime::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{
321µs $DateTime::TimeZone::Local::Unix::VERSION = '1.63';
4}
5
# spent 9µs within DateTime::TimeZone::Local::Unix::BEGIN@5 which was called: # once (9µs+0s) by Module::Runtime::require_module at line 7
BEGIN {
615µs $DateTime::TimeZone::Local::Unix::AUTHORITY = 'cpan:DROLSKY';
7121µs19µs}
# spent 9µs making 1 call to DateTime::TimeZone::Local::Unix::BEGIN@5
8
9235µs213µs
# spent 10µs (7+3) within DateTime::TimeZone::Local::Unix::BEGIN@9 which was called: # once (7µs+3µs) by Module::Runtime::require_module at line 9
use strict;
# spent 10µs making 1 call to DateTime::TimeZone::Local::Unix::BEGIN@9 # spent 3µs making 1 call to strict::import
10225µs217µs
# spent 12µs (7+5) within DateTime::TimeZone::Local::Unix::BEGIN@10 which was called: # once (7µs+5µs) by Module::Runtime::require_module at line 10
use warnings;
# spent 12µs making 1 call to DateTime::TimeZone::Local::Unix::BEGIN@10 # spent 5µs making 1 call to warnings::import
11
123131µs33.38ms
# spent 3.33ms (3.03+297µs) within DateTime::TimeZone::Local::Unix::BEGIN@12 which was called: # once (3.03ms+297µs) by Module::Runtime::require_module at line 12
use Cwd 3;
# spent 3.33ms making 1 call to DateTime::TimeZone::Local::Unix::BEGIN@12 # spent 39µs making 1 call to Exporter::import # spent 12µs making 1 call to UNIVERSAL::VERSION
132922µs253µs
# spent 31µs (9+22) within DateTime::TimeZone::Local::Unix::BEGIN@13 which was called: # once (9µs+22µs) by Module::Runtime::require_module at line 13
use parent 'DateTime::TimeZone::Local';
# spent 31µs making 1 call to DateTime::TimeZone::Local::Unix::BEGIN@13 # spent 22µs making 1 call to parent::import
14
15
# spent 2µs within DateTime::TimeZone::Local::Unix::Methods which was called: # once (2µs+0s) by DateTime::TimeZone::Local::TimeZone at line 21 of DateTime/TimeZone/Local.pm
sub Methods {
1613µs return qw(
17 FromEnv
18 FromEtcLocaltime
19 FromEtcTimezone
20 FromEtcTIMEZONE
21 FromEtcSysconfigClock
22 FromEtcDefaultInit
23 );
24}
25
2613µs
# spent 800ns within DateTime::TimeZone::Local::Unix::EnvVars which was called: # once (800ns+0s) by DateTime::TimeZone::Local::FromEnv at line 67 of DateTime/TimeZone/Local.pm
sub EnvVars { return 'TZ' }
27
28
# spent 52.7ms (62µs+52.6) within DateTime::TimeZone::Local::Unix::FromEtcLocaltime which was called: # once (62µs+52.6ms) by DateTime::TimeZone::Local::TimeZone at line 22 of DateTime/TimeZone/Local.pm
sub FromEtcLocaltime {
29728µs my $class = shift;
30
31 my $lt_file = '/etc/localtime';
32
3326µs return unless -r $lt_file && -s _;
# spent 6µs making 1 call to DateTime::TimeZone::Local::Unix::CORE:fteread # spent 300ns making 1 call to DateTime::TimeZone::Local::Unix::CORE:ftsize
34
35 my $real_name;
3615µs if ( -l $lt_file ) {
# spent 5µ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
42144.4ms $real_name ||= $class->_FindMatchingZoneinfoFile($lt_file);
43
44315µs if ( defined $real_name ) {
45114µs my ( $vol, $dirs, $file ) = File::Spec->splitpath($real_name);
# spent 14µs making 1 call to File::Spec::Unix::splitpath
46
47 my @parts
4871µs13µs = grep { defined && length } File::Spec->splitdir($dirs), $file;
# spent 3µs making 1 call to File::Spec::Unix::splitdir
49
50 foreach my $x ( reverse 0 .. $#parts ) {
51810µs my $name = (
52 $x < $#parts
53 ? join '/', @parts[ $x .. $#parts ]
54 : $parts[$x]
55 );
56
57 my $tz;
58 {
5965µs local $@;
60 local $SIG{__DIE__};
6128µs20s $tz = eval { DateTime::TimeZone->new( name => $name ) };
# spent 8.23ms making 2 calls to DateTime::TimeZone::new, avg 4.12ms/call, recursion: max depth 1, sum of overlapping time 8.23ms
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 44.4ms (6.11+38.2) within DateTime::TimeZone::Local::Unix::_FindMatchingZoneinfoFile which was called: # once (6.11ms+38.2ms) by DateTime::TimeZone::Local::Unix::FromEtcLocaltime at line 42
sub _FindMatchingZoneinfoFile {
7913330µs my $class = shift;
80 my $file_to_match = shift;
81
8213µs return unless -d '/usr/share/zoneinfo';
# spent 3µ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
8815µs my $size = -s $file_to_match;
# spent 5µs making 1 call to DateTime::TimeZone::Local::Unix::CORE:ftsize
89
90 my $real_name;
91 local $@;
92 local $SIG{__DIE__};
93 local $_;
9415µs eval {
95 File::Find::find(
96 {
97
# spent 17.0ms (8.71+8.29) 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 10µs/call: # 1082 times (5.62ms+5.80ms) by File::Find::_find_dir at line 749 of File/Find.pm, avg 11µs/call # 475 times (2.50ms+1.94ms) by File::Find::_find_dir at line 781 of File/Find.pm, avg 9µs/call # 78 times (398µs+402µs) by File::Find::_find_dir at line 787 of File/Find.pm, avg 10µs/call # 57 times (184µs+141µs) by File::Find::_find_dir at line 691 of File/Find.pm, avg 6µs/call
wanted => sub {
98169417.8ms41188.29ms if (
# spent 5.19ms making 1692 calls to DateTime::TimeZone::Local::Unix::CORE:ftfile, avg 3µs/call # spent 2.68ms making 1635 calls to DateTime::TimeZone::Local::Unix::CORE:ftlink, avg 2µs/call # spent 195µs making 789 calls to DateTime::TimeZone::Local::Unix::CORE:ftsize, avg 247ns/call # spent 158µs making 1 call to File::Compare::compare # spent 73µ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 },
117136.6ms no_chdir => 1,
# spent 36.6ms making 1 call to File::Find::find
118 },
119 '/usr/share/zoneinfo',
120 );
121 };
122
12317µ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
23713µs1;
238
239# ABSTRACT: Determine the local system's time zone on Unix
240
241__END__
 
# spent 3µs within DateTime::TimeZone::Local::Unix::CORE:ftdir which was called: # once (3µs+0s) by DateTime::TimeZone::Local::Unix::_FindMatchingZoneinfoFile at line 82
sub DateTime::TimeZone::Local::Unix::CORE:ftdir; # opcode
# spent 6µs within DateTime::TimeZone::Local::Unix::CORE:fteread which was called: # once (6µs+0s) by DateTime::TimeZone::Local::Unix::FromEtcLocaltime at line 33
sub DateTime::TimeZone::Local::Unix::CORE:fteread; # opcode
# spent 5.19ms within DateTime::TimeZone::Local::Unix::CORE:ftfile which was called 1692 times, avg 3µs/call: # 1692 times (5.19ms+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
sub DateTime::TimeZone::Local::Unix::CORE:ftfile; # opcode
# spent 2.68ms within DateTime::TimeZone::Local::Unix::CORE:ftlink which was called 1636 times, avg 2µs/call: # 1635 times (2.68ms+0s) by DateTime::TimeZone::Local::Unix::__ANON__[/usr/local/share/perl/5.14.2/DateTime/TimeZone/Local/Unix.pm:116] at line 98, avg 2µs/call # once (5µs+0s) by DateTime::TimeZone::Local::Unix::FromEtcLocaltime at line 36
sub DateTime::TimeZone::Local::Unix::CORE:ftlink; # opcode
# spent 200µs within DateTime::TimeZone::Local::Unix::CORE:ftsize which was called 791 times, avg 253ns/call: # 789 times (195µ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 247ns/call # once (5µs+0s) by DateTime::TimeZone::Local::Unix::_FindMatchingZoneinfoFile at line 88 # once (300ns+0s) by DateTime::TimeZone::Local::Unix::FromEtcLocaltime at line 33
sub DateTime::TimeZone::Local::Unix::CORE:ftsize; # opcode