Filename | /var/www/foswiki11/lib/Foswiki/Iterator/FilterIterator.pm |
Statements | Executed 705330 statements in 1.24s |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
138251 | 5 | 3 | 1.09s | 5.68s | hasNext | Foswiki::Iterator::FilterIterator::
46125 | 2 | 2 | 279ms | 330ms | next | Foswiki::Iterator::FilterIterator::
41 | 1 | 1 | 611µs | 671µs | new | Foswiki::Iterator::FilterIterator::
81 | 3 | 2 | 503µs | 774µs | reset | Foswiki::Iterator::FilterIterator::
1 | 1 | 1 | 12µs | 25µs | BEGIN@13 | Foswiki::Iterator::FilterIterator::
1 | 1 | 1 | 10µs | 15µs | BEGIN@14 | Foswiki::Iterator::FilterIterator::
1 | 1 | 1 | 8µs | 21µs | BEGIN@15 | Foswiki::Iterator::FilterIterator::
1 | 1 | 1 | 4µs | 4µs | BEGIN@17 | Foswiki::Iterator::FilterIterator::
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::FilterIterator | ||||
6 | |||||
7 | Iterator that filters another iterator based on the results from a function. | ||||
8 | |||||
9 | =cut | ||||
10 | |||||
11 | package Foswiki::Iterator::FilterIterator; | ||||
12 | |||||
13 | 2 | 30µs | 2 | 37µs | # spent 25µs (12+12) within Foswiki::Iterator::FilterIterator::BEGIN@13 which was called:
# once (12µs+12µs) by Foswiki::Search::InfoCache::BEGIN@26 at line 13 # spent 25µs making 1 call to Foswiki::Iterator::FilterIterator::BEGIN@13
# spent 12µs making 1 call to strict::import |
14 | 2 | 22µs | 2 | 20µs | # spent 15µs (10+5) within Foswiki::Iterator::FilterIterator::BEGIN@14 which was called:
# once (10µs+5µs) by Foswiki::Search::InfoCache::BEGIN@26 at line 14 # spent 15µs making 1 call to Foswiki::Iterator::FilterIterator::BEGIN@14
# spent 5µs making 1 call to warnings::import |
15 | 2 | 25µs | 2 | 34µs | # spent 21µs (8+13) within Foswiki::Iterator::FilterIterator::BEGIN@15 which was called:
# once (8µs+13µs) by Foswiki::Search::InfoCache::BEGIN@26 at line 15 # spent 21µs making 1 call to Foswiki::Iterator::FilterIterator::BEGIN@15
# spent 13µs making 1 call to Assert::import |
16 | |||||
17 | 2 | 264µs | 1 | 4µs | # spent 4µs within Foswiki::Iterator::FilterIterator::BEGIN@17 which was called:
# once (4µs+0s) by Foswiki::Search::InfoCache::BEGIN@26 at line 17 # spent 4µs making 1 call to Foswiki::Iterator::FilterIterator::BEGIN@17 |
18 | 1 | 10µs | our @ISA = ('Foswiki::Iterator'); | ||
19 | |||||
20 | =begin TML | ||||
21 | |||||
22 | ---++ ClassMethod new( $iter, $sub, $data ) | ||||
23 | Construct a new iterator that will filter $iter based on the results from | ||||
24 | $sub. $sub should return 0 if the next() from $iter should be filtered and | ||||
25 | 1 if it should be treated as the next item in the sequence. | ||||
26 | |||||
27 | $data is an optional arbitrary data item which will be passed to $sub in $_[1] | ||||
28 | |||||
29 | =cut | ||||
30 | |||||
31 | # spent 671µs (611+60) within Foswiki::Iterator::FilterIterator::new which was called 41 times, avg 16µs/call:
# 41 times (611µs+60µs) by Foswiki::Search::InfoCache::getTopicListIterator at line 580 of /var/www/foswiki11/lib/Foswiki/Search/InfoCache.pm, avg 16µs/call | ||||
32 | 41 | 76µs | my ( $class, $iter, $sub, $data ) = @_; | ||
33 | 41 | 54µs | 41 | 36µs | ASSERT( UNIVERSAL::isa( $iter, 'Foswiki::Iterator' ) ) if DEBUG; # spent 36µs making 41 calls to Assert::ASSERTS_OFF, avg 888ns/call |
34 | 41 | 42µs | 41 | 23µs | ASSERT( ref($sub) eq 'CODE' ) if DEBUG; # spent 23µs making 41 calls to Assert::ASSERTS_OFF, avg 568ns/call |
35 | 41 | 63µs | my $this = bless( {}, $class ); | ||
36 | 41 | 42µs | $this->{iterator} = $iter; | ||
37 | 41 | 18µs | $this->{filter} = $sub; | ||
38 | 41 | 20µs | $this->{data} = $data; | ||
39 | 41 | 23µs | $this->{next} = undef; | ||
40 | 41 | 30µs | $this->{pending} = 0; | ||
41 | 41 | 126µs | return $this; | ||
42 | } | ||||
43 | |||||
44 | # See Foswiki::Iterator for a description of the general iterator contract | ||||
45 | # spent 5.68s (1.09+4.59) within Foswiki::Iterator::FilterIterator::hasNext which was called 138251 times, avg 41µs/call:
# 92000 times (1.01s+4.55s) by Foswiki::Store::SearchAlgorithms::Forking::search at line 104 of /var/www/foswiki11/lib/Foswiki/Store/SearchAlgorithms/Forking.pm, avg 60µs/call
# 46125 times (50.9ms+0s) by Foswiki::Iterator::FilterIterator::next at line 61, avg 1µs/call
# 85 times (28.7ms+29.4ms) by Foswiki::Store::QueryAlgorithms::BruteForce::_webQuery at line 215 of /var/www/foswiki11/lib/Foswiki/Store/QueryAlgorithms/BruteForce.pm, avg 683µs/call
# 40 times (7.56ms+5.02ms) by Foswiki::Store::SearchAlgorithms::Forking::search at line 99 of /var/www/foswiki11/lib/Foswiki/Store/SearchAlgorithms/Forking.pm, avg 315µs/call
# once (209µs+391µs) by Foswiki::Store::QueryAlgorithms::BruteForce::_webQuery at line 209 of /var/www/foswiki11/lib/Foswiki/Store/QueryAlgorithms/BruteForce.pm | ||||
46 | 138251 | 36.1ms | my $this = shift; | ||
47 | 138251 | 399ms | return 1 if $this->{pending}; | ||
48 | 46206 | 71.1ms | 46206 | 224ms | while ( $this->{iterator}->hasNext() ) { # spent 224ms making 46206 calls to Foswiki::ListIterator::hasNext, avg 5µs/call |
49 | 52483 | 100ms | 52483 | 445ms | $this->{next} = $this->{iterator}->next(); # spent 445ms making 52483 calls to Foswiki::ListIterator::next, avg 8µs/call |
50 | 52483 | 121ms | 58841 | 3.92s | if ( &{ $this->{filter} }( $this->{next}, $this->{data} ) ) { # spent 3.89s making 52483 calls to Foswiki::Search::InfoCache::__ANON__[/var/www/foswiki11/lib/Foswiki/Search/InfoCache.pm:579], avg 74µs/call
# spent 28.3ms making 6358 calls to Foswiki::ListIterator::hasNext, avg 4µs/call |
51 | 46125 | 22.0ms | $this->{pending} = 1; | ||
52 | 46125 | 253ms | return 1; | ||
53 | } | ||||
54 | } | ||||
55 | 81 | 343µs | return 0; | ||
56 | } | ||||
57 | |||||
58 | # See Foswiki::Iterator for a description of the general iterator contract | ||||
59 | # spent 330ms (279+50.9) within Foswiki::Iterator::FilterIterator::next which was called 46125 times, avg 7µs/call:
# 46040 times (279ms+50.8ms) by Foswiki::Store::SearchAlgorithms::Forking::search at line 100 of /var/www/foswiki11/lib/Foswiki/Store/SearchAlgorithms/Forking.pm, avg 7µs/call
# 85 times (335µs+89µs) by Foswiki::Store::QueryAlgorithms::BruteForce::_webQuery at line 210 of /var/www/foswiki11/lib/Foswiki/Store/QueryAlgorithms/BruteForce.pm, avg 5µs/call | ||||
60 | 46125 | 12.1ms | my $this = shift; | ||
61 | 46125 | 43.0ms | 46125 | 50.9ms | return unless $this->hasNext(); # spent 50.9ms making 46125 calls to Foswiki::Iterator::FilterIterator::hasNext, avg 1µs/call |
62 | 46125 | 14.6ms | $this->{pending} = 0; | ||
63 | 46125 | 170ms | return $this->{next}; | ||
64 | } | ||||
65 | |||||
66 | # See Foswiki::Iterator for a description of the general iterator contract | ||||
67 | # spent 774µs (503+271) within Foswiki::Iterator::FilterIterator::reset which was called 81 times, avg 10µs/call:
# 40 times (290µs+190µs) by Foswiki::Store::QueryAlgorithms::BruteForce::_webQuery at line 191 of /var/www/foswiki11/lib/Foswiki/Store/QueryAlgorithms/BruteForce.pm, avg 12µs/call
# 40 times (203µs+75µs) by Foswiki::Store::SearchAlgorithms::Forking::search at line 98 of /var/www/foswiki11/lib/Foswiki/Store/SearchAlgorithms/Forking.pm, avg 7µs/call
# once (10µs+5µs) by Foswiki::Store::QueryAlgorithms::BruteForce::_webQuery at line 208 of /var/www/foswiki11/lib/Foswiki/Store/QueryAlgorithms/BruteForce.pm | ||||
68 | 81 | 46µs | my ($this) = @_; | ||
69 | |||||
70 | 81 | 226µs | 81 | 271µs | return unless ( $this->{iterator}->reset() ); # spent 271µs making 81 calls to Foswiki::ListIterator::reset, avg 3µs/call |
71 | 81 | 35µs | $this->{next} = undef; | ||
72 | 81 | 24µs | $this->{pending} = 0; | ||
73 | |||||
74 | 81 | 191µs | return 1; | ||
75 | } | ||||
76 | |||||
77 | 1 | 3µs | 1; | ||
78 | __END__ |