Filename | /usr/local/src/github.com/foswiki/core/lib/Foswiki/Iterator/NumberRangeIterator.pm |
Statements | Executed 48 statements in 712µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
2 | 1 | 1 | 82µs | 82µs | new | Foswiki::Iterator::NumberRangeIterator::
4 | 4 | 2 | 40µs | 40µs | next | Foswiki::Iterator::NumberRangeIterator::
4 | 4 | 2 | 38µs | 38µs | hasNext | Foswiki::Iterator::NumberRangeIterator::
1 | 1 | 1 | 25µs | 25µs | BEGIN@12 | Foswiki::Iterator::NumberRangeIterator::
1 | 1 | 1 | 18µs | 26µs | BEGIN@15 | Foswiki::Iterator::NumberRangeIterator::
1 | 1 | 1 | 17µs | 36µs | BEGIN@16 | Foswiki::Iterator::NumberRangeIterator::
1 | 1 | 1 | 17µs | 57µs | BEGIN@17 | Foswiki::Iterator::NumberRangeIterator::
2 | 2 | 1 | 14µs | 14µ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 | 72µs | 1 | 25µs | # spent 25µs within Foswiki::Iterator::NumberRangeIterator::BEGIN@12 which was called:
# once (25µs+0s) by Foswiki::Store::VC::Handler::BEGIN@38 at line 12 # spent 25µs making 1 call to Foswiki::Iterator::NumberRangeIterator::BEGIN@12 |
13 | 1 | 10µs | our @ISA = ('Foswiki::Iterator'); | ||
14 | |||||
15 | 2 | 45µs | 2 | 34µs | # spent 26µs (18+8) within Foswiki::Iterator::NumberRangeIterator::BEGIN@15 which was called:
# once (18µs+8µs) by Foswiki::Store::VC::Handler::BEGIN@38 at line 15 # spent 26µs making 1 call to Foswiki::Iterator::NumberRangeIterator::BEGIN@15
# spent 8µs making 1 call to strict::import |
16 | 2 | 45µs | 2 | 54µs | # spent 36µs (17+18) within Foswiki::Iterator::NumberRangeIterator::BEGIN@16 which was called:
# once (17µs+18µs) by Foswiki::Store::VC::Handler::BEGIN@38 at line 16 # spent 36µs making 1 call to Foswiki::Iterator::NumberRangeIterator::BEGIN@16
# spent 19µs making 1 call to warnings::import |
17 | 2 | 309µs | 2 | 97µs | # spent 57µs (17+40) within Foswiki::Iterator::NumberRangeIterator::BEGIN@17 which was called:
# once (17µs+40µs) by Foswiki::Store::VC::Handler::BEGIN@38 at line 17 # spent 57µs making 1 call to Foswiki::Iterator::NumberRangeIterator::BEGIN@17
# spent 40µ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 82µs within Foswiki::Iterator::NumberRangeIterator::new which was called 2 times, avg 41µs/call:
# 2 times (82µs+0s) by Foswiki::Store::VC::Handler::getRevisionHistory at line 434 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Store/VC/Handler.pm, avg 41µs/call | ||||
31 | 2 | 13µs | my ( $class, $start, $end, $inc ) = @_; | ||
32 | 2 | 4µs | $inc ||= 1; | ||
33 | 2 | 62µ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 38µs within Foswiki::Iterator::NumberRangeIterator::hasNext which was called 4 times, avg 9µs/call:
# once (12µs+0s) by Foswiki::Iterator::all at line 85 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Iterator.pm
# once (10µs+0s) by Foswiki::UI::View::view at line 128 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/UI/View.pm
# once (8µs+0s) by Foswiki::UI::View::view at line 129 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/UI/View.pm
# once (8µs+0s) by Foswiki::Iterator::all at line 86 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Iterator.pm | ||||
45 | 4 | 6µs | my $this = shift; | ||
46 | 4 | 8µs | if ( $this->{inc} > 0 ) { | ||
47 | return $this->{cur} <= $this->{end}; | ||||
48 | } | ||||
49 | else { | ||||
50 | 4 | 45µs | return $this->{cur} >= $this->{end}; | ||
51 | } | ||||
52 | } | ||||
53 | |||||
54 | # spent 40µs within Foswiki::Iterator::NumberRangeIterator::next which was called 4 times, avg 10µs/call:
# once (11µs+0s) by Foswiki::UI::View::view at line 122 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/UI/View.pm
# once (10µs+0s) by Foswiki::Iterator::all at line 86 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Iterator.pm
# once (10µs+0s) by Foswiki::UI::View::view at line 210 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/UI/View.pm
# once (9µs+0s) by Foswiki::UI::View::view at line 129 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/UI/View.pm | ||||
55 | 4 | 6µs | my $this = shift; | ||
56 | 4 | 7µs | my $res = $this->{cur}; | ||
57 | 4 | 8µs | $this->{cur} += $this->{inc}; | ||
58 | 4 | 37µs | return $res; | ||
59 | } | ||||
60 | |||||
61 | # spent 14µs within Foswiki::Iterator::NumberRangeIterator::reset which was called 2 times, avg 7µs/call:
# once (8µs+0s) by Foswiki::UI::View::view at line 209 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/UI/View.pm
# once (7µs+0s) by Foswiki::UI::View::view at line 127 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/UI/View.pm | ||||
62 | 2 | 4µs | my $this = shift; | ||
63 | 2 | 26µs | $this->{cur} = $this->{start}; | ||
64 | } | ||||
65 | |||||
66 | 1 | 6µs | 1; | ||
67 | |||||
68 | __END__ |