Filename | /var/www/foswikidev/core/lib/Foswiki/Iterator/NumberRangeIterator.pm |
Statements | Executed 51 statements in 392µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
2 | 1 | 1 | 20µs | 20µs | new | Foswiki::Iterator::NumberRangeIterator::
1 | 1 | 1 | 13µs | 13µs | BEGIN@12 | Foswiki::Iterator::NumberRangeIterator::
4 | 2 | 1 | 13µs | 13µs | hasNext | Foswiki::Iterator::NumberRangeIterator::
5 | 3 | 2 | 12µs | 12µs | next | Foswiki::Iterator::NumberRangeIterator::
1 | 1 | 1 | 9µs | 21µs | BEGIN@15 | Foswiki::Iterator::NumberRangeIterator::
1 | 1 | 1 | 9µs | 13µs | BEGIN@16 | Foswiki::Iterator::NumberRangeIterator::
1 | 1 | 1 | 9µs | 33µs | BEGIN@17 | Foswiki::Iterator::NumberRangeIterator::
1 | 1 | 1 | 4µs | 4µs | BEGIN@19 | 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 | 44µs | 1 | 13µs | # spent 13µs within Foswiki::Iterator::NumberRangeIterator::BEGIN@12 which was called:
# once (13µs+0s) by Foswiki::Store::Rcs::Handler::BEGIN@44 at line 12 # spent 13µs making 1 call to Foswiki::Iterator::NumberRangeIterator::BEGIN@12 |
13 | 1 | 9µs | our @ISA = ('Foswiki::Iterator'); | ||
14 | |||||
15 | 2 | 25µs | 2 | 33µs | # spent 21µs (9+12) within Foswiki::Iterator::NumberRangeIterator::BEGIN@15 which was called:
# once (9µs+12µs) by Foswiki::Store::Rcs::Handler::BEGIN@44 at line 15 # spent 21µs making 1 call to Foswiki::Iterator::NumberRangeIterator::BEGIN@15
# spent 12µs making 1 call to strict::import |
16 | 2 | 22µs | 2 | 17µs | # spent 13µs (9+4) within Foswiki::Iterator::NumberRangeIterator::BEGIN@16 which was called:
# once (9µs+4µs) by Foswiki::Store::Rcs::Handler::BEGIN@44 at line 16 # spent 13µs making 1 call to Foswiki::Iterator::NumberRangeIterator::BEGIN@16
# spent 4µs making 1 call to warnings::import |
17 | 2 | 49µs | 2 | 58µs | # spent 33µs (9+25) within Foswiki::Iterator::NumberRangeIterator::BEGIN@17 which was called:
# once (9µs+25µs) by Foswiki::Store::Rcs::Handler::BEGIN@44 at line 17 # spent 33µs making 1 call to Foswiki::Iterator::NumberRangeIterator::BEGIN@17
# spent 25µs making 1 call to Exporter::import |
18 | |||||
19 | # spent 4µs within Foswiki::Iterator::NumberRangeIterator::BEGIN@19 which was called:
# once (4µs+0s) by Foswiki::Store::Rcs::Handler::BEGIN@44 at line 24 | ||||
20 | 1 | 7µs | if ( $Foswiki::cfg{UseLocale} ) { | ||
21 | require locale; | ||||
22 | import locale(); | ||||
23 | } | ||||
24 | 1 | 171µs | 1 | 4µs | } # spent 4µs making 1 call to Foswiki::Iterator::NumberRangeIterator::BEGIN@19 |
25 | |||||
26 | =begin TML | ||||
27 | |||||
28 | ---++ ClassMethod new($start, $end, $inc) | ||||
29 | Construct a new iterator from start to end step inc. | ||||
30 | The range is inclusive i.e. if $end == $start, you will get an iterator | ||||
31 | that returns a single value. | ||||
32 | |||||
33 | The iteration step is the absolute value of $inc, and defaults to 1. | ||||
34 | |||||
35 | =cut | ||||
36 | |||||
37 | # spent 20µs within Foswiki::Iterator::NumberRangeIterator::new which was called 2 times, avg 10µs/call:
# 2 times (20µs+0s) by Foswiki::Store::Rcs::Handler::getRevisionHistory at line 493 of /var/www/foswikidev/core/lib/Foswiki/Store/Rcs/Handler.pm, avg 10µs/call | ||||
38 | 2 | 3µs | my ( $class, $start, $end, $inc ) = @_; | ||
39 | 2 | 700ns | $inc ||= 1; | ||
40 | 2 | 19µs | return bless( | ||
41 | { | ||||
42 | start => $start, | ||||
43 | end => $end, | ||||
44 | inc => ( $end > $start ) ? abs($inc) : -abs($inc), | ||||
45 | cur => $start, | ||||
46 | }, | ||||
47 | $class | ||||
48 | ); | ||||
49 | } | ||||
50 | |||||
51 | # spent 13µs within Foswiki::Iterator::NumberRangeIterator::hasNext which was called 4 times, avg 3µs/call:
# 3 times (4µs+0s) by Foswiki::Iterator::all at line 93 of /var/www/foswikidev/core/lib/Foswiki/Iterator.pm, avg 2µs/call
# once (9µs+0s) by Foswiki::Iterator::all at line 92 of /var/www/foswikidev/core/lib/Foswiki/Iterator.pm | ||||
52 | 4 | 1µs | my $this = shift; | ||
53 | 4 | 2µs | if ( $this->{inc} > 0 ) { | ||
54 | return $this->{cur} <= $this->{end}; | ||||
55 | } | ||||
56 | else { | ||||
57 | 4 | 12µs | return $this->{cur} >= $this->{end}; | ||
58 | } | ||||
59 | } | ||||
60 | |||||
61 | # spent 12µs within Foswiki::Iterator::NumberRangeIterator::next which was called 5 times, avg 2µs/call:
# 3 times (5µs+0s) by Foswiki::Iterator::all at line 93 of /var/www/foswikidev/core/lib/Foswiki/Iterator.pm, avg 2µs/call
# once (4µs+0s) by Foswiki::UI::View::view at line 170 of /var/www/foswikidev/core/lib/Foswiki/UI/View.pm
# once (2µs+0s) by Foswiki::UI::View::view at line 273 of /var/www/foswikidev/core/lib/Foswiki/UI/View.pm | ||||
62 | 5 | 1µs | my $this = shift; | ||
63 | 5 | 2µs | my $res = $this->{cur}; | ||
64 | 5 | 2µs | $this->{cur} += $this->{inc}; | ||
65 | 5 | 14µs | return $res; | ||
66 | } | ||||
67 | |||||
68 | # spent 3µs within Foswiki::Iterator::NumberRangeIterator::reset which was called:
# once (3µs+0s) by Foswiki::UI::View::view at line 272 of /var/www/foswikidev/core/lib/Foswiki/UI/View.pm | ||||
69 | 1 | 600ns | my $this = shift; | ||
70 | 1 | 4µs | $this->{cur} = $this->{start}; | ||
71 | } | ||||
72 | |||||
73 | 1 | 3µs | 1; | ||
74 | |||||
75 | __END__ |