Filename | /usr/share/perl5/Date/Manip/Obj.pm |
Statements | Executed 278 statements in 3.38ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 20.5ms | 21.6ms | BEGIN@16 | Date::Manip::Obj::
1 | 1 | 1 | 15.8ms | 16.7ms | BEGIN@15 | Date::Manip::Obj::
1 | 1 | 1 | 10.7ms | 11.4ms | new_recur | Date::Manip::Obj::
1 | 1 | 1 | 5.42ms | 6.07ms | new_delta | Date::Manip::Obj::
9 | 7 | 2 | 824µs | 19.6ms | new (recurses: max depth 1, inclusive time 18.8ms) | Date::Manip::Obj::
27 | 2 | 1 | 62µs | 62µs | CORE:match (opcode) | Date::Manip::Obj::
27 | 2 | 1 | 60µs | 60µs | CORE:regcomp (opcode) | Date::Manip::Obj::
1 | 1 | 1 | 26µs | 1.62ms | config | Date::Manip::Obj::
7 | 1 | 1 | 26µs | 26µs | _init_final | Date::Manip::Obj::
1 | 1 | 1 | 20µs | 103µs | BEGIN@13 | Date::Manip::Obj::
1 | 1 | 1 | 18µs | 69µs | BEGIN@18 | Date::Manip::Obj::
1 | 1 | 1 | 17µs | 31µs | BEGIN@10 | Date::Manip::Obj::
1 | 1 | 1 | 16µs | 84µs | BEGIN@9 | Date::Manip::Obj::
1 | 1 | 1 | 13µs | 69µs | new_date | Date::Manip::Obj::
2 | 2 | 1 | 12µs | 12µs | CORE:qr (opcode) | Date::Manip::Obj::
1 | 1 | 1 | 11µs | 204µs | BEGIN@12 | Date::Manip::Obj::
1 | 1 | 1 | 11µs | 14µs | BEGIN@11 | Date::Manip::Obj::
1 | 1 | 1 | 6µs | 6µs | tz | Date::Manip::Obj::
1 | 1 | 1 | 6µs | 6µs | base | Date::Manip::Obj::
0 | 0 | 0 | 0s | 0s | _init_args | Date::Manip::Obj::
0 | 0 | 0 | 0s | 0s | err | Date::Manip::Obj::
0 | 0 | 0 | 0s | 0s | is_date | Date::Manip::Obj::
0 | 0 | 0 | 0s | 0s | is_delta | Date::Manip::Obj::
0 | 0 | 0 | 0s | 0s | is_recur | Date::Manip::Obj::
0 | 0 | 0 | 0s | 0s | new_config | Date::Manip::Obj::
0 | 0 | 0 | 0s | 0s | version | Date::Manip::Obj::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
0 | 1 | 84µs | Profile data that couldn't be associated with a specific line: # spent 84µs making 1 call to Date::Manip::Obj::BEGIN@9 | ||
1 | 1 | 8µs | package Date::Manip::Obj; | ||
2 | # Copyright (c) 2008-2010 Sullivan Beck. All rights reserved. | ||||
3 | # This program is free software; you can redistribute it and/or modify it | ||||
4 | # under the same terms as Perl itself. | ||||
5 | |||||
6 | ######################################################################## | ||||
7 | ######################################################################## | ||||
8 | |||||
9 | 4 | 92µs | 1 | 68µs | # spent 84µs (16+68) within Date::Manip::Obj::BEGIN@9 which was called:
# once (16µs+68µs) by Date::Manip::Date::BEGIN@14 at line 0 # spent 68µs making 1 call to feature::import |
10 | 3 | 30µs | 2 | 44µs | # spent 31µs (17+14) within Date::Manip::Obj::BEGIN@10 which was called:
# once (17µs+14µs) by Date::Manip::Date::BEGIN@14 at line 10 # spent 31µs making 1 call to Date::Manip::Obj::BEGIN@10
# spent 14µs making 1 call to warnings::import |
11 | 3 | 30µs | 2 | 17µs | # spent 14µs (11+3) within Date::Manip::Obj::BEGIN@11 which was called:
# once (11µs+3µs) by Date::Manip::Date::BEGIN@14 at line 11 # spent 14µs making 1 call to Date::Manip::Obj::BEGIN@11
# spent 3µs making 1 call to strict::import |
12 | 3 | 36µs | 2 | 397µs | # spent 204µs (11+193) within Date::Manip::Obj::BEGIN@12 which was called:
# once (11µs+193µs) by Date::Manip::Date::BEGIN@14 at line 12 # spent 204µs making 1 call to Date::Manip::Obj::BEGIN@12
# spent 193µs making 1 call to Exporter::import |
13 | 3 | 39µs | 2 | 187µs | # spent 103µs (20+84) within Date::Manip::Obj::BEGIN@13 which was called:
# once (20µs+84µs) by Date::Manip::Date::BEGIN@14 at line 13 # spent 103µs making 1 call to Date::Manip::Obj::BEGIN@13
# spent 84µs making 1 call to Exporter::import |
14 | |||||
15 | 3 | 140µs | 1 | 16.7ms | # spent 16.7ms (15.8+968µs) within Date::Manip::Obj::BEGIN@15 which was called:
# once (15.8ms+968µs) by Date::Manip::Date::BEGIN@14 at line 15 # spent 16.7ms making 1 call to Date::Manip::Obj::BEGIN@15 |
16 | 3 | 293µs | 1 | 21.6ms | # spent 21.6ms (20.5+1.06) within Date::Manip::Obj::BEGIN@16 which was called:
# once (20.5ms+1.06ms) by Date::Manip::Date::BEGIN@14 at line 16 # spent 21.6ms making 1 call to Date::Manip::Obj::BEGIN@16 |
17 | |||||
18 | 3 | 1.29ms | 2 | 120µs | # spent 69µs (18+51) within Date::Manip::Obj::BEGIN@18 which was called:
# once (18µs+51µs) by Date::Manip::Date::BEGIN@14 at line 18 # spent 69µs making 1 call to Date::Manip::Obj::BEGIN@18
# spent 51µs making 1 call to vars::import |
19 | 1 | 800ns | $VERSION='6.11'; | ||
20 | |||||
21 | ######################################################################## | ||||
22 | # METHODS | ||||
23 | ######################################################################## | ||||
24 | |||||
25 | 1 | 17µs | 1 | 10µs | my $dmo_rx = qr/^Date::Manip::(Base|TZ|Date|Delta|Recur)$/; # spent 10µs making 1 call to Date::Manip::Obj::CORE:qr |
26 | 1 | 5µs | 1 | 2µs | my $dmh_rx = qr/^Date::Manip::(Date|Delta|Recur)$/; # spent 2µs making 1 call to Date::Manip::Obj::CORE:qr |
27 | |||||
28 | # spent 19.6ms (824µs+18.7) within Date::Manip::Obj::new which was called 9 times, avg 2.17ms/call:
# 2 times (174µs+-174µs) by Date::Manip::Obj::new at line 104, avg 0s/call
# 2 times (113µs+-113µs) by Date::Manip::Obj::new at line 103, avg 0s/call
# once (229µs+12.4ms) by C4::Overdues::BEGIN@25 at line 66 of Date/Manip.pm
# once (97µs+6.53ms) by C4::Overdues::BEGIN@25 at line 69 of Date/Manip.pm
# once (80µs+81µs) by Date::Manip::Obj::new_recur at line 238
# once (92µs+34µs) by Date::Manip::Obj::new_delta at line 233
# once (39µs+17µs) by Date::Manip::Obj::new_date at line 228 | ||||
29 | 216 | 926µs | my(@args) = @_; | ||
30 | my(@allargs) = @args; | ||||
31 | |||||
32 | # Get the object or class. | ||||
33 | |||||
34 | my($self,$class); | ||||
35 | |||||
36 | 36 | 99µs | if (ref($args[0]) =~ $dmo_rx) { # spent 53µs making 18 calls to Date::Manip::Obj::CORE:match, avg 3µs/call
# spent 47µs making 18 calls to Date::Manip::Obj::CORE:regcomp, avg 3µs/call | ||
37 | $self = shift(@args); | ||||
38 | $class = ref($args[0]); | ||||
39 | |||||
40 | } elsif ($args[0] =~ $dmo_rx) { | ||||
41 | $class = shift(@args); | ||||
42 | |||||
43 | } else { | ||||
44 | warn "ERROR: [new] first argument must be a Date::Manip class/object\n"; | ||||
45 | return undef; | ||||
46 | } | ||||
47 | |||||
48 | # Get an existing Date::Manip::* object, if any | ||||
49 | |||||
50 | my $obj; | ||||
51 | 18 | 22µs | if ($self) { # spent 13µs making 9 calls to Date::Manip::Obj::CORE:regcomp, avg 1µs/call
# spent 9µs making 9 calls to Date::Manip::Obj::CORE:match, avg 1µs/call | ||
52 | $obj = $self; | ||||
53 | } elsif (ref($args[0]) =~ $dmo_rx) { | ||||
54 | $obj = shift(@args); | ||||
55 | } | ||||
56 | |||||
57 | # Find out if there are any config options (which will be the | ||||
58 | # final argument). | ||||
59 | |||||
60 | my @config; | ||||
61 | if (@args && ref($args[$#args]) eq 'ARRAY') { | ||||
62 | @config = @{ pop(@args) }; | ||||
63 | } | ||||
64 | |||||
65 | # Any other arguments at this point are passed to _init. | ||||
66 | |||||
67 | # Get Base/TZ objects from an existing object | ||||
68 | |||||
69 | my($dmt,$dmb); | ||||
70 | |||||
71 | if ($obj) { | ||||
72 | $dmb = $$obj{'objs'}{'base'} if (exists $$obj{'objs'}{'base'}); | ||||
73 | $dmt = $$obj{'objs'}{'tz'} if (exists $$obj{'objs'}{'tz'}); | ||||
74 | } | ||||
75 | |||||
76 | # Create a new empty object. | ||||
77 | |||||
78 | my $new = { | ||||
79 | 'objs' => {}, | ||||
80 | 'data' => {}, | ||||
81 | 'args' => [ @args ], | ||||
82 | 'err' => '', | ||||
83 | }; | ||||
84 | |||||
85 | # Create new Base/TZ objects if necessary | ||||
86 | |||||
87 | my $init = 1; | ||||
88 | if (! $dmb) { | ||||
89 | |||||
90 | # We're creating first-time instances: | ||||
91 | # $dmb = new Date::Manip::Base [,\@config]; | ||||
92 | # $dmt = new Date::Manip::TZ [,\@config]; | ||||
93 | # $obj = new Date::Manip::* [,\@config]; | ||||
94 | |||||
95 | if ($class eq 'Date::Manip::Base') { | ||||
96 | $dmb = $new; | ||||
97 | |||||
98 | } elsif ($class eq 'Date::Manip::TZ') { | ||||
99 | $dmb = new Date::Manip::Base; | ||||
100 | $dmt = $new; | ||||
101 | |||||
102 | } else { | ||||
103 | 2 | 0s | $dmb = new Date::Manip::Base; # spent 17.5ms making 2 calls to Date::Manip::Obj::new, avg 8.76ms/call, recursion: max depth 1, sum of overlapping time 17.5ms | ||
104 | 2 | 0s | $dmt = new Date::Manip::TZ $dmb; # spent 1.28ms making 2 calls to Date::Manip::Obj::new, avg 640µs/call, recursion: max depth 1, sum of overlapping time 1.28ms | ||
105 | } | ||||
106 | |||||
107 | } elsif ($class eq 'Date::Manip::Base') { | ||||
108 | |||||
109 | # $dmb = new Date::Manip::Base $obj [,\@config]; | ||||
110 | # This should create a new instance of a Base object | ||||
111 | # with the same configuration. | ||||
112 | |||||
113 | $new = dclone($dmb); | ||||
114 | $$new{'cache'} = $$dmb{'cache'}; | ||||
115 | $dmb = $new; | ||||
116 | $init = 0; | ||||
117 | |||||
118 | } elsif (@config && $class eq 'Date::Manip::TZ') { | ||||
119 | |||||
120 | # $dmt = new Date::Manip::TZ $obj,\@config; | ||||
121 | |||||
122 | $dmb = new Date::Manip::Base $obj,[@config]; | ||||
123 | $dmt = $new; | ||||
124 | |||||
125 | } elsif (@config) { | ||||
126 | |||||
127 | # $obj2 = new Date::Manip::* $obj1,\@config; | ||||
128 | |||||
129 | $dmb = new Date::Manip::Base $obj,\@config; | ||||
130 | $dmt = new Date::Manip::TZ $dmb; | ||||
131 | |||||
132 | } elsif ($class eq 'Date::Manip::TZ') { | ||||
133 | |||||
134 | # $dmt = new Date::Manip::TZ $obj; | ||||
135 | # Reuse $dmb object | ||||
136 | |||||
137 | $dmt = $new; | ||||
138 | |||||
139 | } else { | ||||
140 | |||||
141 | # $obj2 = new Date::Manip::* $boj1; | ||||
142 | # Use existing $dmb/$dmt | ||||
143 | |||||
144 | } | ||||
145 | |||||
146 | bless $new,$class; | ||||
147 | |||||
148 | $$new{'objs'}{'base'} = $dmb; | ||||
149 | $$new{'objs'}{'tz'} = $dmt if ($dmt); | ||||
150 | $$dmb{'objs'}{'tz'} = $dmt if ($dmt); | ||||
151 | |||||
152 | 9 | 17.7ms | $new->_init() unless (! $init); # spent 17.4ms making 2 calls to Date::Manip::Base::_init, avg 8.69ms/call
# spent 170µs making 2 calls to Date::Manip::TZ::_init, avg 85µs/call
# spent 66µs making 1 call to Date::Manip::Recur::_init
# spent 53µs making 3 calls to Date::Manip::Date::_init, avg 18µs/call
# spent 13µs making 1 call to Date::Manip::Delta::_init | ||
153 | |||||
154 | # Apply configuration options and parse the string. | ||||
155 | |||||
156 | if (@config) { | ||||
157 | $dmb->config(@config); | ||||
158 | } | ||||
159 | |||||
160 | $new->_init_args() if (@args); | ||||
161 | 9 | 928µs | $new->_init_final(); # spent 902µs making 2 calls to Date::Manip::TZ::_init_final, avg 451µs/call
# spent 26µs making 7 calls to Date::Manip::Obj::_init_final, avg 4µs/call | ||
162 | |||||
163 | return $new; | ||||
164 | } | ||||
165 | |||||
166 | sub _init_args { | ||||
167 | my($self) = @_; | ||||
168 | |||||
169 | my @args = @{ $$self{'args'} }; | ||||
170 | if (@args) { | ||||
171 | warn "WARNING: [new] invalid arguments: @args\n"; | ||||
172 | } | ||||
173 | } | ||||
174 | |||||
175 | # spent 26µs within Date::Manip::Obj::_init_final which was called 7 times, avg 4µs/call:
# 7 times (26µs+0s) by Date::Manip::Obj::new at line 161, avg 4µs/call | ||||
176 | 14 | 36µs | my($self) = @_; | ||
177 | return; | ||||
178 | } | ||||
179 | |||||
180 | sub new_config { | ||||
181 | my(@args) = @_; | ||||
182 | |||||
183 | # Make sure that @opts is passed in as the final argument. | ||||
184 | |||||
185 | if (! @args || | ||||
186 | ! (ref($args[$#args]) eq 'ARRAY')) { | ||||
187 | push(@args,['ignore','ignore']); | ||||
188 | } | ||||
189 | |||||
190 | return new(@args); | ||||
191 | } | ||||
192 | |||||
193 | # spent 6µs within Date::Manip::Obj::base which was called:
# once (6µs+0s) by C4::Overdues::BEGIN@25 at line 73 of Date/Manip.pm | ||||
194 | 2 | 7µs | my($self) = @_; | ||
195 | return $$self{'objs'}{'base'}; | ||||
196 | } | ||||
197 | |||||
198 | # spent 6µs within Date::Manip::Obj::tz which was called:
# once (6µs+0s) by C4::Overdues::BEGIN@25 at line 74 of Date/Manip.pm | ||||
199 | 2 | 7µs | my($self) = @_; | ||
200 | return $$self{'objs'}{'tz'} if (exists $$self{'objs'}{'tz'}); | ||||
201 | return undef; | ||||
202 | } | ||||
203 | |||||
204 | # spent 1.62ms (26µs+1.59) within Date::Manip::Obj::config which was called:
# once (26µs+1.59ms) by C4::Overdues::BEGIN@25 at line 67 of Date/Manip.pm | ||||
205 | 6 | 45µs | my($self,@config) = @_; | ||
206 | my $dmb = $$self{'objs'}{'base'}; | ||||
207 | |||||
208 | while (@config) { | ||||
209 | my $var = shift(@config); | ||||
210 | my $val = shift(@config); | ||||
211 | 1 | 1.59ms | $dmb->_config_var($var,$val); # spent 1.59ms making 1 call to Date::Manip::Base::_config_var | ||
212 | } | ||||
213 | } | ||||
214 | |||||
215 | sub err { | ||||
216 | my($self,$arg) = @_; | ||||
217 | if ($arg) { | ||||
218 | $$self{'err'} = ''; | ||||
219 | return; | ||||
220 | } else { | ||||
221 | return $$self{'err'}; | ||||
222 | } | ||||
223 | } | ||||
224 | |||||
225 | # spent 69µs (13+56) within Date::Manip::Obj::new_date which was called:
# once (13µs+56µs) by C4::Overdues::BEGIN@25 at line 70 of Date/Manip.pm | ||||
226 | 3 | 13µs | my(@args) = @_; | ||
227 | require Date::Manip::Date; | ||||
228 | 1 | 56µs | return new Date::Manip::Date @args; # spent 56µs making 1 call to Date::Manip::Obj::new | ||
229 | } | ||||
230 | # spent 6.07ms (5.42+645µs) within Date::Manip::Obj::new_delta which was called:
# once (5.42ms+645µs) by C4::Overdues::BEGIN@25 at line 71 of Date/Manip.pm | ||||
231 | 3 | 200µs | my(@args) = @_; | ||
232 | require Date::Manip::Delta; | ||||
233 | 1 | 127µs | return new Date::Manip::Delta @args; # spent 127µs making 1 call to Date::Manip::Obj::new | ||
234 | } | ||||
235 | # spent 11.4ms (10.7+720µs) within Date::Manip::Obj::new_recur which was called:
# once (10.7ms+720µs) by C4::Overdues::BEGIN@25 at line 72 of Date/Manip.pm | ||||
236 | 3 | 149µs | my(@args) = @_; | ||
237 | require Date::Manip::Recur; | ||||
238 | 1 | 160µs | return new Date::Manip::Recur @args; # spent 160µs making 1 call to Date::Manip::Obj::new | ||
239 | } | ||||
240 | |||||
241 | sub is_date { | ||||
242 | return 0; | ||||
243 | } | ||||
244 | sub is_delta { | ||||
245 | return 0; | ||||
246 | } | ||||
247 | sub is_recur { | ||||
248 | return 0; | ||||
249 | } | ||||
250 | |||||
251 | sub version { | ||||
252 | my($self,$flag) = @_; | ||||
253 | if ($flag && ref($self) ne "Date::Manip::Base") { | ||||
254 | my $dmb = $$self{'objs'}{'base'}; | ||||
255 | my ($tz) = $dmb->_now("systz"); | ||||
256 | return "$VERSION [$tz]"; | ||||
257 | } else { | ||||
258 | return $VERSION; | ||||
259 | } | ||||
260 | } | ||||
261 | |||||
262 | 1 | 21µs | 1; | ||
263 | # Local Variables: | ||||
264 | # mode: cperl | ||||
265 | # indent-tabs-mode: nil | ||||
266 | # cperl-indent-level: 3 | ||||
267 | # cperl-continued-statement-offset: 2 | ||||
268 | # cperl-continued-brace-offset: 0 | ||||
269 | # cperl-brace-offset: 0 | ||||
270 | # cperl-brace-imaginary-offset: 0 | ||||
271 | # cperl-label-offset: -2 | ||||
272 | # End: | ||||
sub Date::Manip::Obj::CORE:match; # opcode | |||||
sub Date::Manip::Obj::CORE:qr; # opcode | |||||
sub Date::Manip::Obj::CORE:regcomp; # opcode |