← Index
NYTProf Performance Profile   « line view »
For script/ponapi
  Run on Wed Feb 10 15:51:26 2016
Reported on Thu Feb 11 09:43:12 2016

Filename/usr/lib/perl/5.18/Time/Seconds.pm
StatementsExecuted 36 statements in 2.13ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11136µs182µsTime::Seconds::::BEGIN@40Time::Seconds::BEGIN@40
11126µs79µsTime::Seconds::::BEGIN@24Time::Seconds::BEGIN@24
11125µs164µsTime::Seconds::::BEGIN@23Time::Seconds::BEGIN@23
11123µs48µsTime::Seconds::::BEGIN@2Time::Seconds::BEGIN@2
11121µs155µsTime::Seconds::::BEGIN@3Time::Seconds::BEGIN@3
11119µs82µsTime::Seconds::::BEGIN@26Time::Seconds::BEGIN@26
11115µs81µsTime::Seconds::::BEGIN@25Time::Seconds::BEGIN@25
11114µs117µsTime::Seconds::::BEGIN@36Time::Seconds::BEGIN@36
11113µs43µsTime::Seconds::::BEGIN@32Time::Seconds::BEGIN@32
11113µs49µsTime::Seconds::::BEGIN@29Time::Seconds::BEGIN@29
11112µs48µsTime::Seconds::::BEGIN@31Time::Seconds::BEGIN@31
11112µs51µsTime::Seconds::::BEGIN@28Time::Seconds::BEGIN@28
11111µs51µsTime::Seconds::::BEGIN@37Time::Seconds::BEGIN@37
11110µs45µsTime::Seconds::::BEGIN@33Time::Seconds::BEGIN@33
1119µs44µsTime::Seconds::::BEGIN@30Time::Seconds::BEGIN@30
1119µs52µsTime::Seconds::::BEGIN@27Time::Seconds::BEGIN@27
0000s0sTime::Seconds::::_get_ovlvalsTime::Seconds::_get_ovlvals
0000s0sTime::Seconds::::addTime::Seconds::add
0000s0sTime::Seconds::::add_toTime::Seconds::add_to
0000s0sTime::Seconds::::compareTime::Seconds::compare
0000s0sTime::Seconds::::copyTime::Seconds::copy
0000s0sTime::Seconds::::daysTime::Seconds::days
0000s0sTime::Seconds::::financial_monthsTime::Seconds::financial_months
0000s0sTime::Seconds::::hoursTime::Seconds::hours
0000s0sTime::Seconds::::minutesTime::Seconds::minutes
0000s0sTime::Seconds::::monthsTime::Seconds::months
0000s0sTime::Seconds::::newTime::Seconds::new
0000s0sTime::Seconds::::prettyTime::Seconds::pretty
0000s0sTime::Seconds::::secondsTime::Seconds::seconds
0000s0sTime::Seconds::::subtractTime::Seconds::subtract
0000s0sTime::Seconds::::subtract_fromTime::Seconds::subtract_from
0000s0sTime::Seconds::::weeksTime::Seconds::weeks
0000s0sTime::Seconds::::yearsTime::Seconds::years
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Time::Seconds;
2245µs273µs
# spent 48µs (23+25) within Time::Seconds::BEGIN@2 which was called: # once (23µs+25µs) by Time::Piece::BEGIN@7 at line 2
use strict;
# spent 48µs making 1 call to Time::Seconds::BEGIN@2 # spent 25µs making 1 call to strict::import
32118µs2289µs
# spent 155µs (21+134) within Time::Seconds::BEGIN@3 which was called: # once (21µs+134µs) by Time::Piece::BEGIN@7 at line 3
use vars qw/@EXPORT @EXPORT_OK @ISA/;
# spent 155µs making 1 call to Time::Seconds::BEGIN@3 # spent 134µs making 1 call to vars::import
4
5139µs@ISA = 'Exporter';
6
716µs@EXPORT = qw(
8 ONE_MINUTE
9 ONE_HOUR
10 ONE_DAY
11 ONE_WEEK
12 ONE_MONTH
13 ONE_REAL_MONTH
14 ONE_YEAR
15 ONE_REAL_YEAR
16 ONE_FINANCIAL_MONTH
17 LEAP_YEAR
18 NON_LEAP_YEAR
19);
20
2112µs@EXPORT_OK = qw(cs_sec cs_mon);
22
232114µs2303µs
# spent 164µs (25+139) within Time::Seconds::BEGIN@23 which was called: # once (25µs+139µs) by Time::Piece::BEGIN@7 at line 23
use constant ONE_MINUTE => 60;
# spent 164µs making 1 call to Time::Seconds::BEGIN@23 # spent 139µs making 1 call to constant::import
24247µs2131µs
# spent 79µs (26+52) within Time::Seconds::BEGIN@24 which was called: # once (26µs+52µs) by Time::Piece::BEGIN@7 at line 24
use constant ONE_HOUR => 3_600;
# spent 79µs making 1 call to Time::Seconds::BEGIN@24 # spent 52µs making 1 call to constant::import
25269µs2147µs
# spent 81µs (15+66) within Time::Seconds::BEGIN@25 which was called: # once (15µs+66µs) by Time::Piece::BEGIN@7 at line 25
use constant ONE_DAY => 86_400;
# spent 81µs making 1 call to Time::Seconds::BEGIN@25 # spent 66µs making 1 call to constant::import
26256µs2145µs
# spent 82µs (19+63) within Time::Seconds::BEGIN@26 which was called: # once (19µs+63µs) by Time::Piece::BEGIN@7 at line 26
use constant ONE_WEEK => 604_800;
# spent 82µs making 1 call to Time::Seconds::BEGIN@26 # spent 63µs making 1 call to constant::import
27248µs294µs
# spent 52µs (9+43) within Time::Seconds::BEGIN@27 which was called: # once (9µs+43µs) by Time::Piece::BEGIN@7 at line 27
use constant ONE_MONTH => 2_629_744; # ONE_YEAR / 12
# spent 52µs making 1 call to Time::Seconds::BEGIN@27 # spent 43µs making 1 call to constant::import
28237µs291µs
# spent 51µs (12+40) within Time::Seconds::BEGIN@28 which was called: # once (12µs+40µs) by Time::Piece::BEGIN@7 at line 28
use constant ONE_REAL_MONTH => '1M';
# spent 51µs making 1 call to Time::Seconds::BEGIN@28 # spent 40µs making 1 call to constant::import
29258µs285µs
# spent 49µs (13+36) within Time::Seconds::BEGIN@29 which was called: # once (13µs+36µs) by Time::Piece::BEGIN@7 at line 29
use constant ONE_YEAR => 31_556_930; # 365.24225 days
# spent 49µs making 1 call to Time::Seconds::BEGIN@29 # spent 36µs making 1 call to constant::import
30240µs279µs
# spent 44µs (9+35) within Time::Seconds::BEGIN@30 which was called: # once (9µs+35µs) by Time::Piece::BEGIN@7 at line 30
use constant ONE_REAL_YEAR => '1Y';
# spent 44µs making 1 call to Time::Seconds::BEGIN@30 # spent 35µs making 1 call to constant::import
31237µs285µs
# spent 48µs (12+36) within Time::Seconds::BEGIN@31 which was called: # once (12µs+36µs) by Time::Piece::BEGIN@7 at line 31
use constant ONE_FINANCIAL_MONTH => 2_592_000; # 30 days
# spent 48µs making 1 call to Time::Seconds::BEGIN@31 # spent 36µs making 1 call to constant::import
32239µs273µs
# spent 43µs (13+30) within Time::Seconds::BEGIN@32 which was called: # once (13µs+30µs) by Time::Piece::BEGIN@7 at line 32
use constant LEAP_YEAR => 31_622_400; # 366 * ONE_DAY
# spent 43µs making 1 call to Time::Seconds::BEGIN@32 # spent 30µs making 1 call to constant::import
33256µs280µs
# spent 45µs (10+35) within Time::Seconds::BEGIN@33 which was called: # once (10µs+35µs) by Time::Piece::BEGIN@7 at line 33
use constant NON_LEAP_YEAR => 31_536_000; # 365 * ONE_DAY
# spent 45µs making 1 call to Time::Seconds::BEGIN@33 # spent 35µs making 1 call to constant::import
34
35# hacks to make Time::Piece compile once again
36246µs2221µs
# spent 117µs (14+104) within Time::Seconds::BEGIN@36 which was called: # once (14µs+104µs) by Time::Piece::BEGIN@7 at line 36
use constant cs_sec => 0;
# spent 117µs making 1 call to Time::Seconds::BEGIN@36 # spent 104µs making 1 call to constant::import
372126µs290µs
# spent 51µs (11+40) within Time::Seconds::BEGIN@37 which was called: # once (11µs+40µs) by Time::Piece::BEGIN@7 at line 37
use constant cs_mon => 1;
# spent 51µs making 1 call to Time::Seconds::BEGIN@37 # spent 40µs making 1 call to constant::import
38
39use overload
40130µs1146µs
# spent 182µs (36+146) within Time::Seconds::BEGIN@40 which was called: # once (36µs+146µs) by Time::Piece::BEGIN@7 at line 48
'fallback' => 'undef',
# spent 146µs making 1 call to overload::import
41 '0+' => \&seconds,
42 '""' => \&seconds,
43 '<=>' => \&compare,
44 '+' => \&add,
45 '-' => \&subtract,
46 '-=' => \&subtract_from,
47 '+=' => \&add_to,
4811.11ms1182µs '=' => \&copy;
# spent 182µs making 1 call to Time::Seconds::BEGIN@40
49
50sub new {
51 my $class = shift;
52 my ($val) = @_;
53 $val = 0 unless defined $val;
54 bless \$val, $class;
55}
56
57sub _get_ovlvals {
58 my ($lhs, $rhs, $reverse) = @_;
59 $lhs = $lhs->seconds;
60
61 if (UNIVERSAL::isa($rhs, 'Time::Seconds')) {
62 $rhs = $rhs->seconds;
63 }
64 elsif (ref($rhs)) {
65 die "Can't use non Seconds object in operator overload";
66 }
67
68 if ($reverse) {
69 return $rhs, $lhs;
70 }
71
72 return $lhs, $rhs;
73}
74
75sub compare {
76 my ($lhs, $rhs) = _get_ovlvals(@_);
77 return $lhs <=> $rhs;
78}
79
80sub add {
81 my ($lhs, $rhs) = _get_ovlvals(@_);
82 return Time::Seconds->new($lhs + $rhs);
83}
84
85sub add_to {
86 my $lhs = shift;
87 my $rhs = shift;
88 $rhs = $rhs->seconds if UNIVERSAL::isa($rhs, 'Time::Seconds');
89 $$lhs += $rhs;
90 return $lhs;
91}
92
93sub subtract {
94 my ($lhs, $rhs) = _get_ovlvals(@_);
95 return Time::Seconds->new($lhs - $rhs);
96}
97
98sub subtract_from {
99 my $lhs = shift;
100 my $rhs = shift;
101 $rhs = $rhs->seconds if UNIVERSAL::isa($rhs, 'Time::Seconds');
102 $$lhs -= $rhs;
103 return $lhs;
104}
105
106sub copy {
107 Time::Seconds->new(${$_[0]});
108}
109
110sub seconds {
111 my $s = shift;
112 return $$s;
113}
114
115sub minutes {
116 my $s = shift;
117 return $$s / 60;
118}
119
120sub hours {
121 my $s = shift;
122 $s->minutes / 60;
123}
124
125sub days {
126 my $s = shift;
127 $s->hours / 24;
128}
129
130sub weeks {
131 my $s = shift;
132 $s->days / 7;
133}
134
135sub months {
136 my $s = shift;
137 $s->days / 30.4368541;
138}
139
140sub financial_months {
141 my $s = shift;
142 $s->days / 30;
143}
144
145sub years {
146 my $s = shift;
147 $s->days / 365.24225;
148}
149
150sub pretty {
151 my $s = shift;
152 my $str = "";
153 if ($s < 0) {
154 $s = -$s;
155 $str = "minus ";
156 }
157 if ($s >= ONE_MINUTE) {
158 if ($s >= ONE_HOUR) {
159 if ($s >= ONE_DAY) {
160 my $days = sprintf("%d", $s->days); # does a "floor"
161 $str = $days . " days, ";
162 $s -= ($days * ONE_DAY);
163 }
164 my $hours = sprintf("%d", $s->hours);
165 $str .= $hours . " hours, ";
166 $s -= ($hours * ONE_HOUR);
167 }
168 my $mins = sprintf("%d", $s->minutes);
169 $str .= $mins . " minutes, ";
170 $s -= ($mins * ONE_MINUTE);
171 }
172 $str .= $s->seconds . " seconds";
173 return $str;
174}
175
176114µs1;
177__END__