← Index
NYTProf Performance Profile   « block view • line view • sub view »
For xt/tapper-mcp-scheduler-with-db-longrun.t
  Run on Tue May 22 17:18:39 2012
Reported on Tue May 22 17:23:58 2012

Filename/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/5.12.3/Time/Local.pm
StatementsExecuted 44 statements in 888µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11116µs76µsTime::Local::::BEGIN@8Time::Local::BEGIN@8
11116µs73µsTime::Local::::BEGIN@4Time::Local::BEGIN@4
11115µs19µsTime::Local::::_daygmTime::Local::_daygm
11112µs27µsTime::Local::::BEGIN@5Time::Local::BEGIN@5
11110µs14µsTime::Local::::BEGIN@6Time::Local::BEGIN@6
1118µs52µsTime::Local::::BEGIN@27Time::Local::BEGIN@27
1115µs29µsTime::Local::::BEGIN@29Time::Local::BEGIN@29
1115µs29µsTime::Local::::BEGIN@28Time::Local::BEGIN@28
1114µs4µsTime::Local::::CORE:packTime::Local::CORE:pack (opcode)
0000s0sTime::Local::::_is_leap_yearTime::Local::_is_leap_year
0000s0sTime::Local::::_timegmTime::Local::_timegm
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
31600nsrequire Exporter;
4341µs2131µs
# spent 73µs (16+58) within Time::Local::BEGIN@4 which was called: # once (16µs+58µs) by DateTime::BEGIN@49 at line 4
use Carp;
# spent 73µs making 1 call to Time::Local::BEGIN@4 # spent 58µs making 1 call to Exporter::import
5323µs241µs
# spent 27µs (12+14) within Time::Local::BEGIN@5 which was called: # once (12µs+14µs) by DateTime::BEGIN@49 at line 5
use Config;
# spent 27µs making 1 call to Time::Local::BEGIN@5 # spent 14µs making 1 call to Config::import
6320µs219µs
# spent 14µs (10+5) within Time::Local::BEGIN@6 which was called: # once (10µs+5µs) by DateTime::BEGIN@49 at line 6
use strict;
# spent 14µs making 1 call to Time::Local::BEGIN@6 # spent 5µs making 1 call to strict::import
7
8387µs2135µs
# spent 76µs (16+60) within Time::Local::BEGIN@8 which was called: # once (16µs+60µs) by DateTime::BEGIN@49 at line 8
use vars qw( $VERSION @ISA @EXPORT @EXPORT_OK );
# spent 76µs making 1 call to Time::Local::BEGIN@8 # spent 60µs making 1 call to vars::import
91400ns$VERSION = '1.1901_01';
10
1118µs@ISA = qw( Exporter );
121700ns@EXPORT = qw( timegm timelocal );
131600ns@EXPORT_OK = qw( timegm_nocheck timelocal_nocheck );
14
1511µsmy @MonthDays = ( 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 );
16
17# Determine breakpoint for rolling century
18123µsmy $ThisYear = ( localtime() )[5];
1912µsmy $Breakpoint = ( $ThisYear + 50 ) % 100;
2011µsmy $NextCentury = $ThisYear - $ThisYear % 100;
211200ns$NextCentury += 100 if $Breakpoint < 50;
221200nsmy $Century = $NextCentury - 100;
231200nsmy $SecOff = 0;
24
251400nsmy ( %Options, %Cheat );
26
27320µs295µs
# spent 52µs (8+44) within Time::Local::BEGIN@27 which was called: # once (8µs+44µs) by DateTime::BEGIN@49 at line 27
use constant SECS_PER_MINUTE => 60;
# spent 52µs making 1 call to Time::Local::BEGIN@27 # spent 44µs making 1 call to constant::import
28320µs252µs
# spent 29µs (5+23) within Time::Local::BEGIN@28 which was called: # once (5µs+23µs) by DateTime::BEGIN@49 at line 28
use constant SECS_PER_HOUR => 3600;
# spent 29µs making 1 call to Time::Local::BEGIN@28 # spent 23µs making 1 call to constant::import
293589µs252µs
# spent 29µs (5+23) within Time::Local::BEGIN@29 which was called: # once (5µs+23µs) by DateTime::BEGIN@49 at line 29
use constant SECS_PER_DAY => 86400;
# spent 29µs making 1 call to Time::Local::BEGIN@29 # spent 23µs making 1 call to constant::import
30
31# localtime()'s limit is the year 2**31
321100nsmy $MaxDay = 365 * (2**31);
33
34# Determine the EPOC day for this machine
351100nsmy $Epoc = 0;
3612µsif ( $^O eq 'vos' ) {
37 # work around posix-977 -- VOS doesn't handle dates in the range
38 # 1970-1980.
39 $Epoc = _daygm( 0, 0, 0, 1, 0, 70, 4, 0 );
40}
41elsif ( $^O eq 'MacOS' ) {
42 $MaxDay *=2 if $^O eq 'MacOS'; # time_t unsigned ... quick hack?
43 # MacOS time() is seconds since 1 Jan 1904, localtime
44 # so we need to calculate an offset to apply later
45 $Epoc = 693901;
46 $SecOff = timelocal( localtime(0)) - timelocal( gmtime(0) ) ;
47 $Epoc += _daygm( gmtime(0) );
48}
49else {
50110µs119µs $Epoc = _daygm( gmtime(0) );
# spent 19µs making 1 call to Time::Local::_daygm
51}
52
531800ns%Cheat = (); # clear the cache as epoc has changed
54
55
# spent 19µs (15+4) within Time::Local::_daygm which was called: # once (15µs+4µs) by DateTime::BEGIN@49 at line 50
sub _daygm {
56
57 # This is written in such a byzantine way in order to avoid
58 # lexical variables and sub calls, for speed
59 return $_[3] + (
60117µs14µs $Cheat{ pack( 'ss', @_[ 4, 5 ] ) } ||= do {
# spent 4µs making 1 call to Time::Local::CORE:pack
611400ns my $month = ( $_[4] + 10 ) % 12;
6212µs my $year = $_[5] + 1900 - int($month / 10);
63
6412µs ( ( 365 * $year )
65 + int( $year / 4 )
66 - int( $year / 100 )
67 + int( $year / 400 )
68 + int( ( ( $month * 306 ) + 5 ) / 10 )
69 )
70 - $Epoc;
71 }
72 );
73}
74
75sub _timegm {
76 my $sec =
77 $SecOff + $_[0] + ( SECS_PER_MINUTE * $_[1] ) + ( SECS_PER_HOUR * $_[2] );
78
79 return $sec + ( SECS_PER_DAY * &_daygm );
80}
81
82sub timegm {
83 my ( $sec, $min, $hour, $mday, $month, $year ) = @_;
84
85 if ( $year >= 1000 ) {
86 $year -= 1900;
87 }
88 elsif ( $year < 100 and $year >= 0 ) {
89 $year += ( $year > $Breakpoint ) ? $Century : $NextCentury;
90 }
91
92 unless ( $Options{no_range_check} ) {
93 croak "Month '$month' out of range 0..11"
94 if $month > 11
95 or $month < 0;
96
97 my $md = $MonthDays[$month];
98 ++$md
99 if $month == 1 && _is_leap_year( $year + 1900 );
100
101 croak "Day '$mday' out of range 1..$md" if $mday > $md or $mday < 1;
102 croak "Hour '$hour' out of range 0..23" if $hour > 23 or $hour < 0;
103 croak "Minute '$min' out of range 0..59" if $min > 59 or $min < 0;
104 croak "Second '$sec' out of range 0..59" if $sec > 59 or $sec < 0;
105 }
106
107 my $days = _daygm( undef, undef, undef, $mday, $month, $year );
108
109 unless ($Options{no_range_check} or abs($days) < $MaxDay) {
110 my $msg = '';
111 $msg .= "Day too big - $days > $MaxDay\n" if $days > $MaxDay;
112
113 $year += 1900;
114 $msg .= "Cannot handle date ($sec, $min, $hour, $mday, $month, $year)";
115
116 croak $msg;
117 }
118
119 return $sec
120 + $SecOff
121 + ( SECS_PER_MINUTE * $min )
122 + ( SECS_PER_HOUR * $hour )
123 + ( SECS_PER_DAY * $days );
124}
125
126sub _is_leap_year {
127 return 0 if $_[0] % 4;
128 return 1 if $_[0] % 100;
129 return 0 if $_[0] % 400;
130
131 return 1;
132}
133
134sub timegm_nocheck {
135 local $Options{no_range_check} = 1;
136 return &timegm;
137}
138
139sub timelocal {
140 my $ref_t = &timegm;
141 my $loc_for_ref_t = _timegm( localtime($ref_t) );
142
143 my $zone_off = $loc_for_ref_t - $ref_t
144 or return $loc_for_ref_t;
145
146 # Adjust for timezone
147 my $loc_t = $ref_t - $zone_off;
148
149 # Are we close to a DST change or are we done
150 my $dst_off = $ref_t - _timegm( localtime($loc_t) );
151
152 # If this evaluates to true, it means that the value in $loc_t is
153 # the _second_ hour after a DST change where the local time moves
154 # backward.
155 if ( ! $dst_off &&
156 ( ( $ref_t - SECS_PER_HOUR ) - _timegm( localtime( $loc_t - SECS_PER_HOUR ) ) < 0 )
157 ) {
158 return $loc_t - SECS_PER_HOUR;
159 }
160
161 # Adjust for DST change
162 $loc_t += $dst_off;
163
164 return $loc_t if $dst_off > 0;
165
166 # If the original date was a non-extent gap in a forward DST jump,
167 # we should now have the wrong answer - undo the DST adjustment
168 my ( $s, $m, $h ) = localtime($loc_t);
169 $loc_t -= $dst_off if $s != $_[0] || $m != $_[1] || $h != $_[2];
170
171 return $loc_t;
172}
173
174sub timelocal_nocheck {
175 local $Options{no_range_check} = 1;
176 return &timelocal;
177}
178
179114µs1;
180
181__END__
 
# spent 4µs within Time::Local::CORE:pack which was called: # once (4µs+0s) by Time::Local::_daygm at line 60
sub Time::Local::CORE:pack; # opcode