← Index
NYTProf Performance Profile   « line view »
For ./view
  Run on Fri Jul 31 18:42:36 2015
Reported on Fri Jul 31 18:48:15 2015

Filename/var/www/foswikidev/core/lib/Foswiki/Iterator/FilterIterator.pm
StatementsExecuted 931131 statements in 1.62s
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
173480951.60s57.0sFoswiki::Iterator::FilterIterator::::hasNextFoswiki::Iterator::FilterIterator::hasNext
6364044452ms523msFoswiki::Iterator::FilterIterator::::nextFoswiki::Iterator::FilterIterator::next
120325.12ms5.57msFoswiki::Iterator::FilterIterator::::resetFoswiki::Iterator::FilterIterator::reset
200321.76ms1.76msFoswiki::Iterator::FilterIterator::::newFoswiki::Iterator::FilterIterator::new
8011629µs182msFoswiki::Iterator::FilterIterator::::sortResultsFoswiki::Iterator::FilterIterator::sortResults
11114µs18µsFoswiki::Iterator::FilterIterator::::BEGIN@14Foswiki::Iterator::FilterIterator::BEGIN@14
11113µs25µsFoswiki::Iterator::FilterIterator::::BEGIN@13Foswiki::Iterator::FilterIterator::BEGIN@13
1119µs35µsFoswiki::Iterator::FilterIterator::::BEGIN@15Foswiki::Iterator::FilterIterator::BEGIN@15
1114µs4µsFoswiki::Iterator::FilterIterator::::BEGIN@17Foswiki::Iterator::FilterIterator::BEGIN@17
1114µs4µsFoswiki::Iterator::FilterIterator::::BEGIN@20Foswiki::Iterator::FilterIterator::BEGIN@20
0000s0sFoswiki::Iterator::FilterIterator::::nextWebFoswiki::Iterator::FilterIterator::nextWeb
0000s0sFoswiki::Iterator::FilterIterator::::numberOfTopicsFoswiki::Iterator::FilterIterator::numberOfTopics
0000s0sFoswiki::Iterator::FilterIterator::::skipFoswiki::Iterator::FilterIterator::skip
Call graph for these subroutines as a Graphviz dot language file.
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
7Iterator that filters another iterator based on the results from a function.
8
9=cut
10
11package Foswiki::Iterator::FilterIterator;
12
13230µs238µs
# spent 25µs (13+12) within Foswiki::Iterator::FilterIterator::BEGIN@13 which was called: # once (13µs+12µs) by Foswiki::Search::InfoCache::BEGIN@33 at line 13
use strict;
# spent 25µs making 1 call to Foswiki::Iterator::FilterIterator::BEGIN@13 # spent 12µs making 1 call to strict::import
14224µs223µs
# spent 18µs (14+4) within Foswiki::Iterator::FilterIterator::BEGIN@14 which was called: # once (14µs+4µs) by Foswiki::Search::InfoCache::BEGIN@33 at line 14
use warnings;
# spent 18µs making 1 call to Foswiki::Iterator::FilterIterator::BEGIN@14 # spent 4µs making 1 call to warnings::import
15225µs261µs
# spent 35µs (9+26) within Foswiki::Iterator::FilterIterator::BEGIN@15 which was called: # once (9µs+26µs) by Foswiki::Search::InfoCache::BEGIN@33 at line 15
use Assert;
# spent 35µs making 1 call to Foswiki::Iterator::FilterIterator::BEGIN@15 # spent 26µs making 1 call to Exporter::import
16
17256µs14µs
# spent 4µs within Foswiki::Iterator::FilterIterator::BEGIN@17 which was called: # once (4µs+0s) by Foswiki::Search::InfoCache::BEGIN@33 at line 17
use Foswiki::Iterator ();
# spent 4µs making 1 call to Foswiki::Iterator::FilterIterator::BEGIN@17
1819µsour @ISA = ('Foswiki::Iterator');
19
20
# spent 4µs within Foswiki::Iterator::FilterIterator::BEGIN@20 which was called: # once (4µs+0s) by Foswiki::Search::InfoCache::BEGIN@33 at line 25
BEGIN {
2115µs if ( $Foswiki::cfg{UseLocale} ) {
22 require locale;
23 import locale();
24 }
251476µs14µs}
# spent 4µs making 1 call to Foswiki::Iterator::FilterIterator::BEGIN@20
26
27=begin TML
28
29---++ ClassMethod new( $iter, $sub, $data )
30Construct a new iterator that will filter $iter based on the results from
31$sub. $sub should return 0 if the next() from $iter should be filtered and
321 if it should be treated as the next item in the sequence.
33
34$data is an optional arbitrary data item which will be passed to $sub in $_[1]
35
36=cut
37
38
# spent 1.76ms within Foswiki::Iterator::FilterIterator::new which was called 200 times, avg 9µs/call: # 80 times (1.05ms+0s) by Foswiki::Store::Interfaces::QueryAlgorithm::addACLFilter at line 195 of /var/www/foswikidev/core/lib/Foswiki/Store/Interfaces/QueryAlgorithm.pm, avg 13µs/call # 80 times (477µs+0s) by Foswiki::Store::Interfaces::QueryAlgorithm::getWebIterator at line 237 of /var/www/foswikidev/core/lib/Foswiki/Store/Interfaces/QueryAlgorithm.pm, avg 6µs/call # 40 times (226µs+0s) by Foswiki::Search::InfoCache::getTopicListIterator at line 482 of /var/www/foswikidev/core/lib/Foswiki/Search/InfoCache.pm, avg 6µs/call
sub new {
39200240µs my ( $class, $iter, $sub, $data ) = @_;
40 ASSERT( UNIVERSAL::isa( $iter, 'Foswiki::Iterator' ) ) if DEBUG;
4120024µs ASSERT( ref($sub) eq 'CODE' ) if DEBUG;
42200331µs my $this = bless( {}, $class );
43200209µs $this->{iterator} = $iter;
44200105µs $this->{filter} = $sub;
45200163µs $this->{data} = $data;
46200119µs $this->{next} = undef;
47200128µs $this->{pending} = 0;
48200705µs return $this;
49}
50
51#lie - give the unfiltered count for speed.
52sub numberOfTopics {
53 my $this = shift;
54 return $this->{iterator}->numberOfTopics();
55}
56
57sub nextWeb {
58 my $this = shift;
59 $this->{iterator}->nextWeb();
60}
61
62
# spent 182ms (629µs+182) within Foswiki::Iterator::FilterIterator::sortResults which was called 80 times, avg 2.28ms/call: # 80 times (629µs+182ms) by Foswiki::Store::Interfaces::QueryAlgorithm::query at line 140 of /var/www/foswikidev/core/lib/Foswiki/Store/Interfaces/QueryAlgorithm.pm, avg 2.28ms/call
sub sortResults {
638036µs my $this = shift;
6480735µs80182ms $this->{iterator}->sortResults(@_);
# spent 182ms making 80 calls to Foswiki::Search::ResultSet::sortResults, avg 2.27ms/call
65}
66
67# See Foswiki::Iterator for a description of the general iterator contract
68
# spent 57.0s (1.60+55.4) within Foswiki::Iterator::FilterIterator::hasNext which was called 173480 times, avg 329µs/call: # 92000 times (1.11s+980ms) by Foswiki::Store::SearchAlgorithms::Forking::_search at line 139 of /var/www/foswikidev/core/lib/Foswiki/Store/SearchAlgorithms/Forking.pm, avg 23µs/call # 63640 times (70.3ms+0s) by Foswiki::Iterator::FilterIterator::next at line 128, avg 1µs/call # 8760 times (196ms+27.2s) by Foswiki::Store::QueryAlgorithms::BruteForce::_webQuery at line 188 of /var/www/foswikidev/core/lib/Foswiki/Store/QueryAlgorithms/BruteForce.pm, avg 3.13ms/call # 8760 times (223ms+26.8s) by Foswiki::Search::formatResults at line 1071 of /var/www/foswikidev/core/lib/Foswiki/Search.pm, avg 3.09ms/call # 160 times (1.48ms+16.1ms) by Foswiki::Iterator::ProcessIterator::hasNext at line 52 of /var/www/foswikidev/core/lib/Foswiki/Iterator/ProcessIterator.pm, avg 110µs/call # 40 times (961µs+258ms) by Foswiki::Store::QueryAlgorithms::BruteForce::_webQuery at line 182 of /var/www/foswikidev/core/lib/Foswiki/Store/QueryAlgorithms/BruteForce.pm, avg 6.48ms/call # 40 times (412µs+127ms) by Foswiki::Search::searchWeb at line 386 of /var/www/foswikidev/core/lib/Foswiki/Search.pm, avg 3.20ms/call # 40 times (1.81ms+3.06ms) by Foswiki::Store::SearchAlgorithms::Forking::_search at line 134 of /var/www/foswikidev/core/lib/Foswiki/Store/SearchAlgorithms/Forking.pm, avg 122µs/call # 40 times (64µs+0s) by Foswiki::Search::formatResults at line 750 of /var/www/foswikidev/core/lib/Foswiki/Search.pm, avg 2µs/call
sub hasNext {
6917348042.0ms my $this = shift;
70173480521ms return 1 if $this->{pending};
716388087.7ms63880629ms while ( $this->{iterator}->hasNext() ) {
# spent 414ms making 17600 calls to Foswiki::Search::ResultSet::hasNext, avg 24µs/call # spent 214ms making 46280 calls to Foswiki::ListIterator::hasNext, avg 5µs/call
7267880127ms67880511ms $this->{next} = $this->{iterator}->next();
# spent 413ms making 50360 calls to Foswiki::ListIterator::next, avg 8µs/call # spent 98.1ms making 17520 calls to Foswiki::Search::ResultSet::next, avg 6µs/call
7367880139ms7212054.3s if ( &{ $this->{filter} }( $this->{next}, $this->{data} ) ) {
746364028.5ms $this->{pending} = 1;
7563640261ms return 1;
76 }
77 }
78240820µs return 0;
79}
80
81#WARNING: foswiki has always skipped results before evaluating the filter - this is for speed, but a terrible thing to do
82sub skip {
83 my $this = shift;
84 my $count = shift;
85
86 #ask CAN skip() for faster path
87 if ( $this->{iterator}->can('skip') ) {
88 $count = $this->{iterator}->skip($count);
89
90 if ( $this->{iterator}->hasNext() ) {
91 $this->{next} = $this->{iterator}->next();
92 $this->{pending} = 1;
93 $count--;
94 }
95 }
96 else {
97
98 #brute force
99 while (
100 ( $count > 0
101 ) #must come first - don't want to advance the inner itr if count ==0
102 and $this->{iterator}->hasNext()
103 )
104 {
105 $count--;
106 $this->{next} =
107 $this->{iterator}->next()
108 ; #drain next, so hasNext goes to next element
109 }
110 }
111
112 if ( $count >= 0 ) {
113
114 #skipped past the end of the set
115 $this->{next} = undef;
116 $this->{pending} = 0;
117 }
118 print STDERR
119"--------------------------------------------FilterIterator::skip() => $count\n"
120 if Foswiki::Iterator::MONITOR;
121
122 return $count;
123}
124
125# See Foswiki::Iterator for a description of the general iterator contract
126
# spent 523ms (452+70.3) within Foswiki::Iterator::FilterIterator::next which was called 63640 times, avg 8µs/call: # 46040 times (338ms+53.0ms) by Foswiki::Store::SearchAlgorithms::Forking::_search at line 135 of /var/www/foswikidev/core/lib/Foswiki/Store/SearchAlgorithms/Forking.pm, avg 8µs/call # 8760 times (62.8ms+8.68ms) by Foswiki::Store::QueryAlgorithms::BruteForce::_webQuery at line 183 of /var/www/foswikidev/core/lib/Foswiki/Store/QueryAlgorithms/BruteForce.pm, avg 8µs/call # 8760 times (51.3ms+8.52ms) by Foswiki::Search::formatResults at line 751 of /var/www/foswikidev/core/lib/Foswiki/Search.pm, avg 7µs/call # 80 times (306µs+79µs) by Foswiki::Iterator::ProcessIterator::next at line 58 of /var/www/foswikidev/core/lib/Foswiki/Iterator/ProcessIterator.pm, avg 5µs/call
sub next {
1276364016.6ms my $this = shift;
1286364059.5ms6364070.3ms return unless $this->hasNext();
# spent 70.3ms making 63640 calls to Foswiki::Iterator::FilterIterator::hasNext, avg 1µs/call
1296364020.1ms $this->{pending} = 0;
13063640315ms return $this->{next};
131}
132
133# See Foswiki::Iterator for a description of the general iterator contract
134
# spent 5.57ms (5.12+450µs) within Foswiki::Iterator::FilterIterator::reset which was called 120 times, avg 46µs/call: # 40 times (4.18ms+66µs) by Foswiki::Store::SearchAlgorithms::Forking::_search at line 133 of /var/www/foswikidev/core/lib/Foswiki/Store/SearchAlgorithms/Forking.pm, avg 106µs/call # 40 times (650µs+244µs) by Foswiki::Store::QueryAlgorithms::BruteForce::_webQuery at line 181 of /var/www/foswikidev/core/lib/Foswiki/Store/QueryAlgorithms/BruteForce.pm, avg 22µs/call # 40 times (288µs+140µs) by Foswiki::Store::QueryAlgorithms::BruteForce::_webQuery at line 165 of /var/www/foswikidev/core/lib/Foswiki/Store/QueryAlgorithms/BruteForce.pm, avg 11µs/call
sub reset {
135120101µs my ($this) = @_;
136
137120704µs120450µs return unless ( $this->{iterator}->reset() );
# spent 244µs making 40 calls to Foswiki::Iterator::reset, avg 6µs/call # spent 206µs making 80 calls to Foswiki::ListIterator::reset, avg 3µs/call
1388032µs $this->{next} = undef;
1398025µs $this->{pending} = 0;
140
14180185µs return 1;
142}
143
14413µs1;
145__END__