← Index
NYTProf Performance Profile   « block view • line view • sub view »
For /usr/share/koha/opac/cgi-bin/opac/opac-search.pl
  Run on Tue Oct 15 17:10:45 2013
Reported on Tue Oct 15 17:12:29 2013

Filename/usr/share/perl/5.10/Time/Local.pm
StatementsExecuted 81 statements in 1.37ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
32134µs43µsTime::Local::::_daygmTime::Local::_daygm
21133µs60µsTime::Local::::timegmTime::Local::timegm
11130µs94µsTime::Local::::BEGIN@5Time::Local::BEGIN@5
11124µs126µsTime::Local::::BEGIN@28Time::Local::BEGIN@28
11122µs99µsTime::Local::::BEGIN@4Time::Local::BEGIN@4
11114µs17µsTime::Local::::BEGIN@7Time::Local::BEGIN@7
11112µs16µsTime::Local::::BEGIN@6Time::Local::BEGIN@6
11111µs51µsTime::Local::::BEGIN@29Time::Local::BEGIN@29
11110µs44µsTime::Local::::BEGIN@30Time::Local::BEGIN@30
1119µs75µsTime::Local::::BEGIN@9Time::Local::BEGIN@9
3119µs9µsTime::Local::::CORE:packTime::Local::CORE:pack (opcode)
0000s0sTime::Local::::_is_leap_yearTime::Local::_is_leap_year
0000s0sTime::Local::::_timegmTime::Local::_timegm
0000s0sTime::Local::::timegm_nocheckTime::Local::timegm_nocheck
0000s0sTime::Local::::timelocalTime::Local::timelocal
0000s0sTime::Local::::timelocal_nocheckTime::Local::timelocal_nocheck
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Time::Local;
2
311µsrequire Exporter;
4352µs2175µs
# spent 99µs (22+77) within Time::Local::BEGIN@4 which was called: # once (22µs+77µs) by LWP::UserAgent::BEGIN@12 at line 4
use Carp;
# spent 99µs making 1 call to Time::Local::BEGIN@4 # spent 77µs making 1 call to Exporter::import
5348µs2157µs
# spent 94µs (30+63) within Time::Local::BEGIN@5 which was called: # once (30µs+63µs) by LWP::UserAgent::BEGIN@12 at line 5
use Config;
# spent 94µs making 1 call to Time::Local::BEGIN@5 # spent 63µs making 1 call to Config::import
6326µs221µs
# spent 16µs (12+4) within Time::Local::BEGIN@6 which was called: # once (12µs+4µs) by LWP::UserAgent::BEGIN@12 at line 6
use strict;
# spent 16µs making 1 call to Time::Local::BEGIN@6 # spent 4µs making 1 call to strict::import
7340µs220µs
# spent 17µs (14+3) within Time::Local::BEGIN@7 which was called: # once (14µs+3µs) by LWP::UserAgent::BEGIN@12 at line 7
use integer;
# spent 17µs making 1 call to Time::Local::BEGIN@7 # spent 3µs making 1 call to integer::import
8
93106µs2141µs
# spent 75µs (9+66) within Time::Local::BEGIN@9 which was called: # once (9µs+66µs) by LWP::UserAgent::BEGIN@12 at line 9
use vars qw( $VERSION @ISA @EXPORT @EXPORT_OK );
# spent 75µs making 1 call to Time::Local::BEGIN@9 # spent 66µs making 1 call to vars::import
1011µs$VERSION = '1.1901';
11
12114µs@ISA = qw( Exporter );
1311µs@EXPORT = qw( timegm timelocal );
1411µs@EXPORT_OK = qw( timegm_nocheck timelocal_nocheck );
15
1612µsmy @MonthDays = ( 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 );
17
18# Determine breakpoint for rolling century
19129µsmy $ThisYear = ( localtime() )[5];
2011µsmy $Breakpoint = ( $ThisYear + 50 ) % 100;
211600nsmy $NextCentury = $ThisYear - $ThisYear % 100;
221500ns$NextCentury += 100 if $Breakpoint < 50;
231300nsmy $Century = $NextCentury - 100;
241300nsmy $SecOff = 0;
25
261600nsmy ( %Options, %Cheat );
27
28360µs2227µs
# spent 126µs (24+101) within Time::Local::BEGIN@28 which was called: # once (24µs+101µs) by LWP::UserAgent::BEGIN@12 at line 28
use constant SECS_PER_MINUTE => 60;
# spent 126µs making 1 call to Time::Local::BEGIN@28 # spent 101µs making 1 call to constant::import
29344µs292µs
# spent 51µs (11+40) within Time::Local::BEGIN@29 which was called: # once (11µs+40µs) by LWP::UserAgent::BEGIN@12 at line 29
use constant SECS_PER_HOUR => 3600;
# spent 51µs making 1 call to Time::Local::BEGIN@29 # spent 40µs making 1 call to constant::import
303820µs277µs
# spent 44µs (10+34) within Time::Local::BEGIN@30 which was called: # once (10µs+34µs) by LWP::UserAgent::BEGIN@12 at line 30
use constant SECS_PER_DAY => 86400;
# spent 44µs making 1 call to Time::Local::BEGIN@30 # spent 34µs making 1 call to constant::import
31
321200nsmy $MaxInt;
3314µsif ( $^O eq 'MacOS' ) {
34 # time_t is unsigned...
35 $MaxInt = ( 1 << ( 8 * $Config{ivsize} ) ) - 1;
36}
37else {
38113µs164µs $MaxInt = ( ( 1 << ( 8 * $Config{ivsize} - 2 ) ) - 1 ) * 2 + 1;
# spent 64µs making 1 call to Config::FETCH
39}
40
4111µsmy $MaxDay = int( ( $MaxInt - ( SECS_PER_DAY / 2 ) ) / SECS_PER_DAY ) - 1;
42
43# Determine the EPOC day for this machine
441300nsmy $Epoc = 0;
4512µsif ( $^O eq 'vos' ) {
46 # work around posix-977 -- VOS doesn't handle dates in the range
47 # 1970-1980.
48 $Epoc = _daygm( 0, 0, 0, 1, 0, 70, 4, 0 );
49}
50elsif ( $^O eq 'MacOS' ) {
51 $MaxDay *=2 if $^O eq 'MacOS'; # time_t unsigned ... quick hack?
52 # MacOS time() is seconds since 1 Jan 1904, localtime
53 # so we need to calculate an offset to apply later
54 $Epoc = 693901;
55 $SecOff = timelocal( localtime(0)) - timelocal( gmtime(0) ) ;
56 $Epoc += _daygm( gmtime(0) );
57}
58else {
5916µs117µs $Epoc = _daygm( gmtime(0) );
# spent 17µs making 1 call to Time::Local::_daygm
60}
61
6211µs%Cheat = (); # clear the cache as epoc has changed
63
64
# spent 43µs (34+9) within Time::Local::_daygm which was called 3 times, avg 14µs/call: # 2 times (22µs+5µs) by Time::Local::timegm at line 116, avg 13µs/call # once (13µs+4µs) by LWP::UserAgent::BEGIN@12 at line 59
sub _daygm {
65
66 # This is written in such a byzantine way in order to avoid
67 # lexical variables and sub calls, for speed
68 return $_[3] + (
69339µs39µs $Cheat{ pack( 'ss', @_[ 4, 5 ] ) } ||= do {
# spent 9µs making 3 calls to Time::Local::CORE:pack, avg 3µs/call
7022µs my $month = ( $_[4] + 10 ) % 12;
7122µs my $year = ( $_[5] + 1900 ) - ( $month / 10 );
72
7324µs ( ( 365 * $year )
74 + ( $year / 4 )
75 - ( $year / 100 )
76 + ( $year / 400 )
77 + ( ( ( $month * 306 ) + 5 ) / 10 )
78 )
79 - $Epoc;
80 }
81 );
82}
83
84sub _timegm {
85 my $sec =
86 $SecOff + $_[0] + ( SECS_PER_MINUTE * $_[1] ) + ( SECS_PER_HOUR * $_[2] );
87
88 return $sec + ( SECS_PER_DAY * &_daygm );
89}
90
91
# spent 60µs (33+26) within Time::Local::timegm which was called 2 times, avg 30µs/call: # 2 times (33µs+26µs) by Set::Infinite::BEGIN@18 at line 32 of Set/Infinite/Arithmetic.pm, avg 30µs/call
sub timegm {
9222µs my ( $sec, $min, $hour, $mday, $month, $year ) = @_;
93
9422µs if ( $year >= 1000 ) {
95 $year -= 1900;
96 }
97 elsif ( $year < 100 and $year >= 0 ) {
98 $year += ( $year > $Breakpoint ) ? $Century : $NextCentury;
99 }
100
10122µs unless ( $Options{no_range_check} ) {
10221µs croak "Month '$month' out of range 0..11"
103 if $month > 11
104 or $month < 0;
105
10622µs my $md = $MonthDays[$month];
10721µs ++$md
108 if $month == 1 && _is_leap_year( $year + 1900 );
109
11021µs croak "Day '$mday' out of range 1..$md" if $mday > $md or $mday < 1;
11121µs croak "Hour '$hour' out of range 0..23" if $hour > 23 or $hour < 0;
1122900ns croak "Minute '$min' out of range 0..59" if $min > 59 or $min < 0;
11321µs croak "Second '$sec' out of range 0..59" if $sec > 59 or $sec < 0;
114 }
115
11625µs226µs my $days = _daygm( undef, undef, undef, $mday, $month, $year );
# spent 26µs making 2 calls to Time::Local::_daygm, avg 13µs/call
117
11822µs unless ($Options{no_range_check} or abs($days) < $MaxDay) {
119 my $msg = '';
120 $msg .= "Day too big - $days > $MaxDay\n" if $days > $MaxDay;
121
122 $year += 1900;
123 $msg .= "Cannot handle date ($sec, $min, $hour, $mday, $month, $year)";
124
125 croak $msg;
126 }
127
12828µs return $sec
129 + $SecOff
130 + ( SECS_PER_MINUTE * $min )
131 + ( SECS_PER_HOUR * $hour )
132 + ( SECS_PER_DAY * $days );
133}
134
135sub _is_leap_year {
136 return 0 if $_[0] % 4;
137 return 1 if $_[0] % 100;
138 return 0 if $_[0] % 400;
139
140 return 1;
141}
142
143sub timegm_nocheck {
144 local $Options{no_range_check} = 1;
145 return &timegm;
146}
147
148sub timelocal {
149 my $ref_t = &timegm;
150 my $loc_for_ref_t = _timegm( localtime($ref_t) );
151
152 my $zone_off = $loc_for_ref_t - $ref_t
153 or return $loc_for_ref_t;
154
155 # Adjust for timezone
156 my $loc_t = $ref_t - $zone_off;
157
158 # Are we close to a DST change or are we done
159 my $dst_off = $ref_t - _timegm( localtime($loc_t) );
160
161 # If this evaluates to true, it means that the value in $loc_t is
162 # the _second_ hour after a DST change where the local time moves
163 # backward.
164 if ( ! $dst_off &&
165 ( ( $ref_t - SECS_PER_HOUR ) - _timegm( localtime( $loc_t - SECS_PER_HOUR ) ) < 0 )
166 ) {
167 return $loc_t - SECS_PER_HOUR;
168 }
169
170 # Adjust for DST change
171 $loc_t += $dst_off;
172
173 return $loc_t if $dst_off > 0;
174
175 # If the original date was a non-extent gap in a forward DST jump,
176 # we should now have the wrong answer - undo the DST adjustment
177 my ( $s, $m, $h ) = localtime($loc_t);
178 $loc_t -= $dst_off if $s != $_[0] || $m != $_[1] || $h != $_[2];
179
180 return $loc_t;
181}
182
183sub timelocal_nocheck {
184 local $Options{no_range_check} = 1;
185 return &timelocal;
186}
187
188121µs1;
189
190__END__
 
# spent 9µs within Time::Local::CORE:pack which was called 3 times, avg 3µs/call: # 3 times (9µs+0s) by Time::Local::_daygm at line 69, avg 3µs/call
sub Time::Local::CORE:pack; # opcode