Filename | /var/www/foswikidev/core/lib/Foswiki/Iterator/ProcessIterator.pm |
Statements | Executed 1531 statements in 3.98ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
80 | 1 | 1 | 1.51ms | 108s | all (recurses: max depth 1, inclusive time 49.1s) | Foswiki::Iterator::ProcessIterator::
80 | 1 | 1 | 1.04ms | 108s | next (recurses: max depth 1, inclusive time 49.1s) | Foswiki::Iterator::ProcessIterator::
160 | 2 | 1 | 972µs | 18.5ms | hasNext | Foswiki::Iterator::ProcessIterator::
80 | 1 | 1 | 465µs | 465µs | new | Foswiki::Iterator::ProcessIterator::
1 | 1 | 1 | 13µs | 27µs | BEGIN@14 | Foswiki::Iterator::ProcessIterator::
1 | 1 | 1 | 10µs | 14µs | BEGIN@15 | Foswiki::Iterator::ProcessIterator::
1 | 1 | 1 | 9µs | 35µs | BEGIN@16 | Foswiki::Iterator::ProcessIterator::
1 | 1 | 1 | 5µs | 5µs | BEGIN@21 | Foswiki::Iterator::ProcessIterator::
1 | 1 | 1 | 4µs | 4µs | BEGIN@18 | Foswiki::Iterator::ProcessIterator::
0 | 0 | 0 | 0s | 0s | reset | Foswiki::Iterator::ProcessIterator::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | # See bottom of file for license and copyright information | ||||
2 | |||||
3 | =begin | ||||
4 | |||||
5 | ---+ package Foswiki::Iterator::ProcessIterator | ||||
6 | |||||
7 | Iterator that filters another iterator by calling an external process on each | ||||
8 | element in the iteration. | ||||
9 | |||||
10 | =cut | ||||
11 | |||||
12 | package Foswiki::Iterator::ProcessIterator; | ||||
13 | |||||
14 | 2 | 28µs | 2 | 41µs | # spent 27µs (13+14) within Foswiki::Iterator::ProcessIterator::BEGIN@14 which was called:
# once (13µs+14µs) by Foswiki::Store::Interfaces::QueryAlgorithm::BEGIN@20 at line 14 # spent 27µs making 1 call to Foswiki::Iterator::ProcessIterator::BEGIN@14
# spent 14µs making 1 call to strict::import |
15 | 2 | 23µs | 2 | 18µs | # spent 14µs (10+4) within Foswiki::Iterator::ProcessIterator::BEGIN@15 which was called:
# once (10µs+4µs) by Foswiki::Store::Interfaces::QueryAlgorithm::BEGIN@20 at line 15 # spent 14µs making 1 call to Foswiki::Iterator::ProcessIterator::BEGIN@15
# spent 4µs making 1 call to warnings::import |
16 | 2 | 25µs | 2 | 61µs | # spent 35µs (9+26) within Foswiki::Iterator::ProcessIterator::BEGIN@16 which was called:
# once (9µs+26µs) by Foswiki::Store::Interfaces::QueryAlgorithm::BEGIN@20 at line 16 # spent 35µs making 1 call to Foswiki::Iterator::ProcessIterator::BEGIN@16
# spent 26µs making 1 call to Exporter::import |
17 | |||||
18 | 2 | 72µs | 1 | 4µs | # spent 4µs within Foswiki::Iterator::ProcessIterator::BEGIN@18 which was called:
# once (4µs+0s) by Foswiki::Store::Interfaces::QueryAlgorithm::BEGIN@20 at line 18 # spent 4µs making 1 call to Foswiki::Iterator::ProcessIterator::BEGIN@18 |
19 | 1 | 10µs | our @ISA = ('Foswiki::Iterator'); | ||
20 | |||||
21 | # spent 5µs within Foswiki::Iterator::ProcessIterator::BEGIN@21 which was called:
# once (5µs+0s) by Foswiki::Store::Interfaces::QueryAlgorithm::BEGIN@20 at line 26 | ||||
22 | 1 | 6µs | if ( $Foswiki::cfg{UseLocale} ) { | ||
23 | require locale; | ||||
24 | import locale(); | ||||
25 | } | ||||
26 | 1 | 232µs | 1 | 5µs | } # spent 5µs making 1 call to Foswiki::Iterator::ProcessIterator::BEGIN@21 |
27 | |||||
28 | =begin TML | ||||
29 | |||||
30 | ---++ ClassMethod new( $iter, $sub ) | ||||
31 | Construct a new iterator that will filter $iter by calling | ||||
32 | $sub. on each element. $sub should return the filtered value | ||||
33 | for the element. | ||||
34 | |||||
35 | =cut | ||||
36 | |||||
37 | # spent 465µs within Foswiki::Iterator::ProcessIterator::new which was called 80 times, avg 6µs/call:
# 80 times (465µs+0s) by Foswiki::Store::Interfaces::QueryAlgorithm::query at line 121 of /var/www/foswikidev/core/lib/Foswiki/Store/Interfaces/QueryAlgorithm.pm, avg 6µs/call | ||||
38 | 80 | 80µs | my ( $class, $iter, $sub, $data ) = @_; | ||
39 | ASSERT( UNIVERSAL::isa( $iter, 'Foswiki::Iterator' ) ) if DEBUG; | ||||
40 | 80 | 8µs | ASSERT( ref($sub) eq 'CODE' ) if DEBUG; | ||
41 | 80 | 107µs | my $this = bless( {}, $class ); | ||
42 | 80 | 54µs | $this->{iterator} = $iter; | ||
43 | 80 | 38µs | $this->{process} = $sub; | ||
44 | 80 | 25µs | $this->{data} = $data; | ||
45 | 80 | 31µs | $this->{next} = undef; | ||
46 | 80 | 215µs | return $this; | ||
47 | } | ||||
48 | |||||
49 | # See Foswiki::Iterator for a description of the general iterator contract | ||||
50 | # spent 18.5ms (972µs+17.6) within Foswiki::Iterator::ProcessIterator::hasNext which was called 160 times, avg 116µs/call:
# 80 times (282µs+16.6ms) by Foswiki::Iterator::ProcessIterator::all at line 73, avg 211µs/call
# 80 times (690µs+967µs) by Foswiki::Iterator::ProcessIterator::all at line 74, avg 21µs/call | ||||
51 | 160 | 80µs | my $this = shift; | ||
52 | 160 | 674µs | 160 | 17.6ms | return $this->{iterator}->hasNext(); # spent 17.6ms making 160 calls to Foswiki::Iterator::FilterIterator::hasNext, avg 110µs/call |
53 | } | ||||
54 | |||||
55 | # See Foswiki::Iterator for a description of the general iterator contract | ||||
56 | # spent 108s (1.04ms+108) within Foswiki::Iterator::ProcessIterator::next which was called 80 times, avg 1.35s/call:
# 80 times (1.04ms+108s) by Foswiki::Iterator::ProcessIterator::all at line 74, avg 1.35s/call | ||||
57 | 80 | 26µs | my $this = shift; | ||
58 | 80 | 731µs | 160 | 157s | return &{ $this->{process} }( $this->{iterator}->next(), $this->{data} ); # spent 157s making 80 calls to Foswiki::Store::Interfaces::QueryAlgorithm::__ANON__[/var/www/foswikidev/core/lib/Foswiki/Store/Interfaces/QueryAlgorithm.pm:119], avg 1.97s/call
# spent 384µs making 80 calls to Foswiki::Iterator::FilterIterator::next, avg 5µs/call |
59 | } | ||||
60 | |||||
61 | # See Foswiki::Iterator for a description of the general iterator contract | ||||
62 | sub reset { | ||||
63 | my ($this) = @_; | ||||
64 | |||||
65 | #TODO: need to carefully consider what side effects this has | ||||
66 | |||||
67 | return; | ||||
68 | } | ||||
69 | |||||
70 | # spent 108s (1.51ms+108) within Foswiki::Iterator::ProcessIterator::all which was called 80 times, avg 1.35s/call:
# 80 times (1.51ms+108s) by Foswiki::Store::Interfaces::QueryAlgorithm::query at line 129 of /var/www/foswikidev/core/lib/Foswiki/Store/Interfaces/QueryAlgorithm.pm, avg 1.35s/call | ||||
71 | 80 | 30µs | my $this = shift; | ||
72 | 80 | 21µs | my @results; | ||
73 | 80 | 140µs | 80 | 16.9ms | while ( $this->hasNext() ) { # spent 16.9ms making 80 calls to Foswiki::Iterator::ProcessIterator::hasNext, avg 211µs/call |
74 | 80 | 886µs | 160 | 108s | push( @results, $this->next() ); # spent 157s making 80 calls to Foswiki::Iterator::ProcessIterator::next, avg 1.97s/call, recursion: max depth 1, sum of overlapping time 49.1s
# spent 1.66ms making 80 calls to Foswiki::Iterator::ProcessIterator::hasNext, avg 21µs/call |
75 | } | ||||
76 | 80 | 440µs | return @results; | ||
77 | } | ||||
78 | |||||
79 | 1 | 3µs | 1; | ||
80 | __END__ |