Filename | /usr/local/src/github.com/foswiki/core/lib/Foswiki/Iterator/ProcessIterator.pm |
Statements | Executed 31 statements in 748µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 686µs | 1.65s | next | Foswiki::Iterator::ProcessIterator::
1 | 1 | 1 | 44µs | 51µs | new | Foswiki::Iterator::ProcessIterator::
1 | 1 | 1 | 42µs | 1.65s | all | Foswiki::Iterator::ProcessIterator::
2 | 2 | 1 | 29µs | 736µs | hasNext | Foswiki::Iterator::ProcessIterator::
1 | 1 | 1 | 25µs | 32µs | BEGIN@14 | Foswiki::Iterator::ProcessIterator::
1 | 1 | 1 | 18µs | 56µs | BEGIN@16 | Foswiki::Iterator::ProcessIterator::
1 | 1 | 1 | 17µs | 36µs | BEGIN@15 | Foswiki::Iterator::ProcessIterator::
1 | 1 | 1 | 10µs | 10µ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 | 53µs | 2 | 40µs | # spent 32µs (25+8) within Foswiki::Iterator::ProcessIterator::BEGIN@14 which was called:
# once (25µs+8µs) by Foswiki::Store::Interfaces::QueryAlgorithm::BEGIN@20 at line 14 # spent 32µs making 1 call to Foswiki::Iterator::ProcessIterator::BEGIN@14
# spent 8µs making 1 call to strict::import |
15 | 2 | 45µs | 2 | 55µs | # spent 36µs (17+19) within Foswiki::Iterator::ProcessIterator::BEGIN@15 which was called:
# once (17µs+19µs) by Foswiki::Store::Interfaces::QueryAlgorithm::BEGIN@20 at line 15 # spent 36µs making 1 call to Foswiki::Iterator::ProcessIterator::BEGIN@15
# spent 19µs making 1 call to warnings::import |
16 | 2 | 46µs | 2 | 95µs | # spent 56µs (18+39) within Foswiki::Iterator::ProcessIterator::BEGIN@16 which was called:
# once (18µs+39µs) by Foswiki::Store::Interfaces::QueryAlgorithm::BEGIN@20 at line 16 # spent 56µs making 1 call to Foswiki::Iterator::ProcessIterator::BEGIN@16
# spent 39µs making 1 call to Assert::import |
17 | |||||
18 | 2 | 450µs | 1 | 10µs | # spent 10µs within Foswiki::Iterator::ProcessIterator::BEGIN@18 which was called:
# once (10µs+0s) by Foswiki::Store::Interfaces::QueryAlgorithm::BEGIN@20 at line 18 # spent 10µs making 1 call to Foswiki::Iterator::ProcessIterator::BEGIN@18 |
19 | 1 | 15µs | our @ISA = ('Foswiki::Iterator'); | ||
20 | |||||
21 | =begin TML | ||||
22 | |||||
23 | ---++ ClassMethod new( $iter, $sub ) | ||||
24 | Construct a new iterator that will filter $iter by calling | ||||
25 | $sub. on each element. $sub should return the filtered value | ||||
26 | for the element. | ||||
27 | |||||
28 | =cut | ||||
29 | |||||
30 | # spent 51µs (44+7) within Foswiki::Iterator::ProcessIterator::new which was called:
# once (44µs+7µs) by Foswiki::Store::Interfaces::QueryAlgorithm::query at line 111 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Store/Interfaces/QueryAlgorithm.pm | ||||
31 | 9 | 37µs | my ( $class, $iter, $sub, $data ) = @_; | ||
32 | 1 | 3µs | ASSERT( UNIVERSAL::isa( $iter, 'Foswiki::Iterator' ) ) if DEBUG; # spent 3µs making 1 call to Assert::ASSERTS_OFF | ||
33 | 1 | 3µs | ASSERT( ref($sub) eq 'CODE' ) if DEBUG; # spent 3µs making 1 call to Assert::ASSERTS_OFF | ||
34 | my $this = bless( {}, $class ); | ||||
35 | $this->{iterator} = $iter; | ||||
36 | $this->{process} = $sub; | ||||
37 | $this->{data} = $data; | ||||
38 | $this->{next} = undef; | ||||
39 | return $this; | ||||
40 | } | ||||
41 | |||||
42 | # See Foswiki::Iterator for a description of the general iterator contract | ||||
43 | sub hasNext { | ||||
44 | 4 | 31µs | my $this = shift; | ||
45 | 2 | 706µs | return $this->{iterator}->hasNext(); # spent 706µs making 2 calls to Foswiki::Iterator::FilterIterator::hasNext, avg 353µs/call | ||
46 | } | ||||
47 | |||||
48 | # See Foswiki::Iterator for a description of the general iterator contract | ||||
49 | # spent 1.65s (686µs+1.65) within Foswiki::Iterator::ProcessIterator::next which was called:
# once (686µs+1.65s) by Foswiki::Iterator::ProcessIterator::all at line 67 | ||||
50 | 2 | 26µs | my $this = shift; | ||
51 | 1 | 2µs | 2 | 1.65s | return &{ $this->{process} }( $this->{iterator}->next(), $this->{data} ); # spent 1.65s making 1 call to Foswiki::Store::Interfaces::QueryAlgorithm::__ANON__[/usr/local/src/github.com/foswiki/core/lib/Foswiki/Store/Interfaces/QueryAlgorithm.pm:109]
# spent 22µs making 1 call to Foswiki::Iterator::FilterIterator::next |
52 | } | ||||
53 | |||||
54 | # See Foswiki::Iterator for a description of the general iterator contract | ||||
55 | sub reset { | ||||
56 | my ($this) = @_; | ||||
57 | |||||
58 | #TODO: need to carefully consider what side effects this has | ||||
59 | |||||
60 | return; | ||||
61 | } | ||||
62 | |||||
63 | # spent 1.65s (42µs+1.65) within Foswiki::Iterator::ProcessIterator::all which was called:
# once (42µs+1.65s) by Foswiki::Store::Interfaces::QueryAlgorithm::query at line 119 of /usr/local/src/github.com/foswiki/core/lib/Foswiki/Store/Interfaces/QueryAlgorithm.pm | ||||
64 | 4 | 19µs | my $this = shift; | ||
65 | my @results; | ||||
66 | 1 | 688µs | while ( $this->hasNext() ) { # spent 688µs making 1 call to Foswiki::Iterator::ProcessIterator::hasNext | ||
67 | 1 | 18µs | 2 | 1.65s | push( @results, $this->next() ); # spent 1.65s making 1 call to Foswiki::Iterator::ProcessIterator::next
# spent 47µs making 1 call to Foswiki::Iterator::ProcessIterator::hasNext |
68 | } | ||||
69 | return @results; | ||||
70 | } | ||||
71 | |||||
72 | 1 | 6µs | 1; | ||
73 | __END__ |