← 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 11:58:52 2013
Reported on Tue Oct 15 12:01:04 2013

Filename/usr/share/perl/5.10/Time/Local.pm
StatementsExecuted 81 statements in 1.58ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
111157µs161µsTime::Local::::BEGIN@7Time::Local::BEGIN@7
11165µs69µsTime::Local::::BEGIN@6Time::Local::BEGIN@6
21135µs61µsTime::Local::::timegmTime::Local::timegm
32135µs44µsTime::Local::::_daygmTime::Local::_daygm
11122µs104µsTime::Local::::BEGIN@4Time::Local::BEGIN@4
11116µs36µsTime::Local::::BEGIN@5Time::Local::BEGIN@5
11113µs80µsTime::Local::::BEGIN@28Time::Local::BEGIN@28
11113µs119µsTime::Local::::BEGIN@9Time::Local::BEGIN@9
11110µs47µsTime::Local::::BEGIN@30Time::Local::BEGIN@30
3119µs9µsTime::Local::::CORE:packTime::Local::CORE:pack (opcode)
1119µs42µsTime::Local::::BEGIN@29Time::Local::BEGIN@29
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;
4336µs2186µs
# spent 104µs (22+82) within Time::Local::BEGIN@4 which was called: # once (22µs+82µs) by LWP::UserAgent::BEGIN@12 at line 4
use Carp;
# spent 104µs making 1 call to Time::Local::BEGIN@4 # spent 82µs making 1 call to Exporter::import
5333µs256µs
# spent 36µs (16+20) within Time::Local::BEGIN@5 which was called: # once (16µs+20µs) by LWP::UserAgent::BEGIN@12 at line 5
use Config;
# spent 36µs making 1 call to Time::Local::BEGIN@5 # spent 20µs making 1 call to Config::import
6355µs274µs
# spent 69µs (65+4) within Time::Local::BEGIN@6 which was called: # once (65µs+4µs) by LWP::UserAgent::BEGIN@12 at line 6
use strict;
# spent 69µs making 1 call to Time::Local::BEGIN@6 # spent 4µs making 1 call to strict::import
73175µs2165µs
# spent 161µs (157+4) within Time::Local::BEGIN@7 which was called: # once (157µs+4µs) by LWP::UserAgent::BEGIN@12 at line 7
use integer;
# spent 161µs making 1 call to Time::Local::BEGIN@7 # spent 4µs making 1 call to integer::import
8
93121µs2225µs
# spent 119µs (13+106) within Time::Local::BEGIN@9 which was called: # once (13µs+106µs) by LWP::UserAgent::BEGIN@12 at line 9
use vars qw( $VERSION @ISA @EXPORT @EXPORT_OK );
# spent 119µs making 1 call to Time::Local::BEGIN@9 # spent 106µs making 1 call to vars::import
101600ns$VERSION = '1.1901';
11
12112µs@ISA = qw( Exporter );
131900ns@EXPORT = qw( timegm timelocal );
1411µs@EXPORT_OK = qw( timegm_nocheck timelocal_nocheck );
15
1611µsmy @MonthDays = ( 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 );
17
18# Determine breakpoint for rolling century
19137µsmy $ThisYear = ( localtime() )[5];
2013µsmy $Breakpoint = ( $ThisYear + 50 ) % 100;
211800nsmy $NextCentury = $ThisYear - $ThisYear % 100;
221600ns$NextCentury += 100 if $Breakpoint < 50;
231300nsmy $Century = $NextCentury - 100;
241200nsmy $SecOff = 0;
25
261700nsmy ( %Options, %Cheat );
27
28342µs2147µs
# spent 80µs (13+67) within Time::Local::BEGIN@28 which was called: # once (13µs+67µs) by LWP::UserAgent::BEGIN@12 at line 28
use constant SECS_PER_MINUTE => 60;
# spent 80µs making 1 call to Time::Local::BEGIN@28 # spent 67µs making 1 call to constant::import
293171µs276µs
# spent 42µs (9+33) within Time::Local::BEGIN@29 which was called: # once (9µs+33µs) by LWP::UserAgent::BEGIN@12 at line 29
use constant SECS_PER_HOUR => 3600;
# spent 42µs making 1 call to Time::Local::BEGIN@29 # spent 33µs making 1 call to constant::import
303754µs283µs
# spent 47µs (10+36) within Time::Local::BEGIN@30 which was called: # once (10µs+36µs) by LWP::UserAgent::BEGIN@12 at line 30
use constant SECS_PER_DAY => 86400;
# spent 47µs making 1 call to Time::Local::BEGIN@30 # spent 36µs making 1 call to constant::import
31
321300nsmy $MaxInt;
3314µsif ( $^O eq 'MacOS' ) {
34 # time_t is unsigned...
35 $MaxInt = ( 1 << ( 8 * $Config{ivsize} ) ) - 1;
36}
37else {
38115µs169µs $MaxInt = ( ( 1 << ( 8 * $Config{ivsize} - 2 ) ) - 1 ) * 2 + 1;
# spent 69µ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
441500nsmy $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µs118µs $Epoc = _daygm( gmtime(0) );
# spent 18µs making 1 call to Time::Local::_daygm
60}
61
6211µs%Cheat = (); # clear the cache as epoc has changed
63
64
# spent 44µs (35+9) within Time::Local::_daygm which was called 3 times, avg 15µs/call: # 2 times (21µs+5µs) by Time::Local::timegm at line 116, avg 13µs/call # once (14µs+5µ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] + (
69947µs39µs $Cheat{ pack( 'ss', @_[ 4, 5 ] ) } ||= do {
# spent 9µs making 3 calls to Time::Local::CORE:pack, avg 3µs/call
70 my $month = ( $_[4] + 10 ) % 12;
71 my $year = ( $_[5] + 1900 ) - ( $month / 10 );
72
73 ( ( 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 61µs (35+26) within Time::Local::timegm which was called 2 times, avg 31µs/call: # 2 times (35µs+26µs) by Set::Infinite::BEGIN@18 at line 32 of Set/Infinite/Arithmetic.pm, avg 31µs/call
sub timegm {
922633µs my ( $sec, $min, $hour, $mday, $month, $year ) = @_;
93
94 if ( $year >= 1000 ) {
95 $year -= 1900;
96 }
97 elsif ( $year < 100 and $year >= 0 ) {
98 $year += ( $year > $Breakpoint ) ? $Century : $NextCentury;
99 }
100
101 unless ( $Options{no_range_check} ) {
102 croak "Month '$month' out of range 0..11"
103 if $month > 11
104 or $month < 0;
105
106 my $md = $MonthDays[$month];
107 ++$md
108 if $month == 1 && _is_leap_year( $year + 1900 );
109
110 croak "Day '$mday' out of range 1..$md" if $mday > $md or $mday < 1;
111 croak "Hour '$hour' out of range 0..23" if $hour > 23 or $hour < 0;
112 croak "Minute '$min' out of range 0..59" if $min > 59 or $min < 0;
113 croak "Second '$sec' out of range 0..59" if $sec > 59 or $sec < 0;
114 }
115
116226µ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
118 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
128 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
188122µ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