Filename | /var/www/foswiki11/lib/Foswiki/Iterator/NumberRangeIterator.pm |
Statements | Executed 50 statements in 389µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
2 | 1 | 1 | 51µs | 51µs | new | Foswiki::Iterator::NumberRangeIterator::
5 | 3 | 2 | 15µs | 15µs | next | Foswiki::Iterator::NumberRangeIterator::
1 | 1 | 1 | 14µs | 14µs | BEGIN@12 | Foswiki::Iterator::NumberRangeIterator::
4 | 2 | 1 | 11µs | 11µs | hasNext | Foswiki::Iterator::NumberRangeIterator::
1 | 1 | 1 | 9µs | 15µs | BEGIN@16 | Foswiki::Iterator::NumberRangeIterator::
1 | 1 | 1 | 8µs | 23µs | BEGIN@17 | Foswiki::Iterator::NumberRangeIterator::
1 | 1 | 1 | 8µs | 21µs | BEGIN@15 | Foswiki::Iterator::NumberRangeIterator::
1 | 1 | 1 | 3µs | 3µs | reset | Foswiki::Iterator::NumberRangeIterator::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | # See bottom of file for license and copyright information | ||||
2 | |||||
3 | =begin TML | ||||
4 | |||||
5 | ---+ package Foswiki::Iterator::NumberRangeIterator | ||||
6 | |||||
7 | Iterator over a range of integer values, with programmable increment. | ||||
8 | |||||
9 | =cut | ||||
10 | |||||
11 | package Foswiki::Iterator::NumberRangeIterator; | ||||
12 | 2 | 41µs | 1 | 14µs | # spent 14µs within Foswiki::Iterator::NumberRangeIterator::BEGIN@12 which was called:
# once (14µs+0s) by Foswiki::Store::VC::Handler::BEGIN@38 at line 12 # spent 14µs making 1 call to Foswiki::Iterator::NumberRangeIterator::BEGIN@12 |
13 | 1 | 7µs | our @ISA = ('Foswiki::Iterator'); | ||
14 | |||||
15 | 2 | 25µs | 2 | 34µs | # spent 21µs (8+13) within Foswiki::Iterator::NumberRangeIterator::BEGIN@15 which was called:
# once (8µs+13µs) by Foswiki::Store::VC::Handler::BEGIN@38 at line 15 # spent 21µs making 1 call to Foswiki::Iterator::NumberRangeIterator::BEGIN@15
# spent 13µs making 1 call to strict::import |
16 | 2 | 23µs | 2 | 20µs | # spent 15µs (9+5) within Foswiki::Iterator::NumberRangeIterator::BEGIN@16 which was called:
# once (9µs+5µs) by Foswiki::Store::VC::Handler::BEGIN@38 at line 16 # spent 15µs making 1 call to Foswiki::Iterator::NumberRangeIterator::BEGIN@16
# spent 5µs making 1 call to warnings::import |
17 | 2 | 176µs | 2 | 37µs | # spent 23µs (8+14) within Foswiki::Iterator::NumberRangeIterator::BEGIN@17 which was called:
# once (8µs+14µs) by Foswiki::Store::VC::Handler::BEGIN@38 at line 17 # spent 23µs making 1 call to Foswiki::Iterator::NumberRangeIterator::BEGIN@17
# spent 14µs making 1 call to Assert::import |
18 | |||||
19 | =begin TML | ||||
20 | |||||
21 | ---++ ClassMethod new($start, $end, $inc) | ||||
22 | Construct a new iterator from start to end step inc. | ||||
23 | The range is inclusive i.e. if $end == $start, you will get an iterator | ||||
24 | that returns a single value. | ||||
25 | |||||
26 | The iteration step is the absolute value of $inc, and defaults to 1. | ||||
27 | |||||
28 | =cut | ||||
29 | |||||
30 | # spent 51µs within Foswiki::Iterator::NumberRangeIterator::new which was called 2 times, avg 25µs/call:
# 2 times (51µs+0s) by Foswiki::Store::VC::Handler::getRevisionHistory at line 434 of /var/www/foswiki11/lib/Foswiki/Store/VC/Handler.pm, avg 25µs/call | ||||
31 | 2 | 6µs | my ( $class, $start, $end, $inc ) = @_; | ||
32 | 2 | 1µs | $inc ||= 1; | ||
33 | 2 | 46µs | return bless( | ||
34 | { | ||||
35 | start => $start, | ||||
36 | end => $end, | ||||
37 | inc => ( $end > $start ) ? abs($inc) : -abs($inc), | ||||
38 | cur => $start, | ||||
39 | }, | ||||
40 | $class | ||||
41 | ); | ||||
42 | } | ||||
43 | |||||
44 | # spent 11µs within Foswiki::Iterator::NumberRangeIterator::hasNext which was called 4 times, avg 3µs/call:
# 3 times (5µs+0s) by Foswiki::Iterator::all at line 86 of /var/www/foswiki11/lib/Foswiki/Iterator.pm, avg 2µs/call
# once (6µs+0s) by Foswiki::Iterator::all at line 85 of /var/www/foswiki11/lib/Foswiki/Iterator.pm | ||||
45 | 4 | 1µs | my $this = shift; | ||
46 | 4 | 2µs | if ( $this->{inc} > 0 ) { | ||
47 | return $this->{cur} <= $this->{end}; | ||||
48 | } | ||||
49 | else { | ||||
50 | 4 | 17µs | return $this->{cur} >= $this->{end}; | ||
51 | } | ||||
52 | } | ||||
53 | |||||
54 | # spent 15µs within Foswiki::Iterator::NumberRangeIterator::next which was called 5 times, avg 3µs/call:
# 3 times (8µs+0s) by Foswiki::Iterator::all at line 86 of /var/www/foswiki11/lib/Foswiki/Iterator.pm, avg 3µs/call
# once (4µs+0s) by Foswiki::UI::View::view at line 132 of /var/www/foswiki11/lib/Foswiki/UI/View.pm
# once (3µs+0s) by Foswiki::UI::View::view at line 220 of /var/www/foswiki11/lib/Foswiki/UI/View.pm | ||||
55 | 5 | 1µs | my $this = shift; | ||
56 | 5 | 2µs | my $res = $this->{cur}; | ||
57 | 5 | 4µs | $this->{cur} += $this->{inc}; | ||
58 | 5 | 17µs | return $res; | ||
59 | } | ||||
60 | |||||
61 | # spent 3µs within Foswiki::Iterator::NumberRangeIterator::reset which was called:
# once (3µs+0s) by Foswiki::UI::View::view at line 219 of /var/www/foswiki11/lib/Foswiki/UI/View.pm | ||||
62 | 1 | 900ns | my $this = shift; | ||
63 | 1 | 13µs | $this->{cur} = $this->{start}; | ||
64 | } | ||||
65 | |||||
66 | 1 | 3µs | 1; | ||
67 | |||||
68 | __END__ |