Filename | /var/www/foswikidev/core/lib/Foswiki/Store/SearchAlgorithms/Forking.pm |
Statements | Executed 203681 statements in 907ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
40 | 1 | 1 | 1.42s | 48.8s | _search | Foswiki::Store::SearchAlgorithms::Forking::
40 | 1 | 1 | 24.1ms | 49.1s | _webQuery | Foswiki::Store::SearchAlgorithms::Forking::
1 | 1 | 1 | 23µs | 31µs | new | Foswiki::Store::SearchAlgorithms::Forking::
1 | 1 | 1 | 16µs | 29µs | BEGIN@13 | Foswiki::Store::SearchAlgorithms::Forking::
1 | 1 | 1 | 11µs | 16µs | BEGIN@14 | Foswiki::Store::SearchAlgorithms::Forking::
1 | 1 | 1 | 10µs | 38µs | BEGIN@15 | Foswiki::Store::SearchAlgorithms::Forking::
1 | 1 | 1 | 9µs | 40µs | BEGIN@34 | Foswiki::Store::SearchAlgorithms::Forking::
1 | 1 | 1 | 5µs | 5µs | BEGIN@17 | Foswiki::Store::SearchAlgorithms::Forking::
1 | 1 | 1 | 5µs | 5µs | BEGIN@36 | Foswiki::Store::SearchAlgorithms::Forking::
1 | 1 | 1 | 4µs | 4µs | BEGIN@21 | Foswiki::Store::SearchAlgorithms::Forking::
1 | 1 | 1 | 4µs | 4µs | BEGIN@30 | Foswiki::Store::SearchAlgorithms::Forking::
1 | 1 | 1 | 4µs | 4µs | BEGIN@20 | Foswiki::Store::SearchAlgorithms::Forking::
1 | 1 | 1 | 4µs | 4µs | BEGIN@29 | Foswiki::Store::SearchAlgorithms::Forking::
1 | 1 | 1 | 4µs | 4µs | BEGIN@25 | Foswiki::Store::SearchAlgorithms::Forking::
1 | 1 | 1 | 3µs | 3µs | BEGIN@24 | Foswiki::Store::SearchAlgorithms::Forking::
1 | 1 | 1 | 3µs | 3µs | BEGIN@22 | Foswiki::Store::SearchAlgorithms::Forking::
1 | 1 | 1 | 3µs | 3µs | BEGIN@31 | Foswiki::Store::SearchAlgorithms::Forking::
1 | 1 | 1 | 3µs | 3µs | BEGIN@26 | Foswiki::Store::SearchAlgorithms::Forking::
1 | 1 | 1 | 3µs | 3µs | BEGIN@27 | Foswiki::Store::SearchAlgorithms::Forking::
1 | 1 | 1 | 3µs | 3µs | BEGIN@23 | Foswiki::Store::SearchAlgorithms::Forking::
1 | 1 | 1 | 3µs | 3µs | BEGIN@28 | Foswiki::Store::SearchAlgorithms::Forking::
1 | 1 | 1 | 3µs | 3µs | BEGIN@32 | Foswiki::Store::SearchAlgorithms::Forking::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | # See bottom of file for license and copyright information | ||||
2 | package Foswiki::Store::SearchAlgorithms::Forking; | ||||
3 | |||||
4 | =begin TML | ||||
5 | |||||
6 | ---+ package Foswiki::Store::SearchAlgorithms::Forking | ||||
7 | Implements Foswiki::Store::Interfaces::SearchAlgorithm | ||||
8 | |||||
9 | Forking implementation of flat file store search. Uses grep. | ||||
10 | |||||
11 | =cut | ||||
12 | |||||
13 | 2 | 31µs | 2 | 43µs | # spent 29µs (16+13) within Foswiki::Store::SearchAlgorithms::Forking::BEGIN@13 which was called:
# once (16µs+13µs) by Foswiki::Store::Rcs::Store::query at line 13 # spent 29µs making 1 call to Foswiki::Store::SearchAlgorithms::Forking::BEGIN@13
# spent 13µs making 1 call to strict::import |
14 | 2 | 25µs | 2 | 20µs | # spent 16µs (11+4) within Foswiki::Store::SearchAlgorithms::Forking::BEGIN@14 which was called:
# once (11µs+4µs) by Foswiki::Store::Rcs::Store::query at line 14 # spent 16µs making 1 call to Foswiki::Store::SearchAlgorithms::Forking::BEGIN@14
# spent 4µs making 1 call to warnings::import |
15 | 2 | 29µs | 2 | 66µs | # spent 38µs (10+28) within Foswiki::Store::SearchAlgorithms::Forking::BEGIN@15 which was called:
# once (10µs+28µs) by Foswiki::Store::Rcs::Store::query at line 15 # spent 38µs making 1 call to Foswiki::Store::SearchAlgorithms::Forking::BEGIN@15
# spent 28µs making 1 call to Exporter::import |
16 | |||||
17 | 2 | 34µs | 1 | 5µs | # spent 5µs within Foswiki::Store::SearchAlgorithms::Forking::BEGIN@17 which was called:
# once (5µs+0s) by Foswiki::Store::Rcs::Store::query at line 17 # spent 5µs making 1 call to Foswiki::Store::SearchAlgorithms::Forking::BEGIN@17 |
18 | 1 | 8µs | our @ISA = ('Foswiki::Store::Interfaces::QueryAlgorithm'); | ||
19 | |||||
20 | 2 | 20µs | 1 | 4µs | # spent 4µs within Foswiki::Store::SearchAlgorithms::Forking::BEGIN@20 which was called:
# once (4µs+0s) by Foswiki::Store::Rcs::Store::query at line 20 # spent 4µs making 1 call to Foswiki::Store::SearchAlgorithms::Forking::BEGIN@20 |
21 | 2 | 19µs | 1 | 4µs | # spent 4µs within Foswiki::Store::SearchAlgorithms::Forking::BEGIN@21 which was called:
# once (4µs+0s) by Foswiki::Store::Rcs::Store::query at line 21 # spent 4µs making 1 call to Foswiki::Store::SearchAlgorithms::Forking::BEGIN@21 |
22 | 2 | 17µs | 1 | 3µs | # spent 3µs within Foswiki::Store::SearchAlgorithms::Forking::BEGIN@22 which was called:
# once (3µs+0s) by Foswiki::Store::Rcs::Store::query at line 22 # spent 3µs making 1 call to Foswiki::Store::SearchAlgorithms::Forking::BEGIN@22 |
23 | 2 | 18µs | 1 | 3µs | # spent 3µs within Foswiki::Store::SearchAlgorithms::Forking::BEGIN@23 which was called:
# once (3µs+0s) by Foswiki::Store::Rcs::Store::query at line 23 # spent 3µs making 1 call to Foswiki::Store::SearchAlgorithms::Forking::BEGIN@23 |
24 | 2 | 18µs | 1 | 3µs | # spent 3µs within Foswiki::Store::SearchAlgorithms::Forking::BEGIN@24 which was called:
# once (3µs+0s) by Foswiki::Store::Rcs::Store::query at line 24 # spent 3µs making 1 call to Foswiki::Store::SearchAlgorithms::Forking::BEGIN@24 |
25 | 2 | 19µs | 1 | 4µs | # spent 4µs within Foswiki::Store::SearchAlgorithms::Forking::BEGIN@25 which was called:
# once (4µs+0s) by Foswiki::Store::Rcs::Store::query at line 25 # spent 4µs making 1 call to Foswiki::Store::SearchAlgorithms::Forking::BEGIN@25 |
26 | 2 | 17µs | 1 | 3µs | # spent 3µs within Foswiki::Store::SearchAlgorithms::Forking::BEGIN@26 which was called:
# once (3µs+0s) by Foswiki::Store::Rcs::Store::query at line 26 # spent 3µs making 1 call to Foswiki::Store::SearchAlgorithms::Forking::BEGIN@26 |
27 | 2 | 17µs | 1 | 3µs | # spent 3µs within Foswiki::Store::SearchAlgorithms::Forking::BEGIN@27 which was called:
# once (3µs+0s) by Foswiki::Store::Rcs::Store::query at line 27 # spent 3µs making 1 call to Foswiki::Store::SearchAlgorithms::Forking::BEGIN@27 |
28 | 2 | 18µs | 1 | 3µs | # spent 3µs within Foswiki::Store::SearchAlgorithms::Forking::BEGIN@28 which was called:
# once (3µs+0s) by Foswiki::Store::Rcs::Store::query at line 28 # spent 3µs making 1 call to Foswiki::Store::SearchAlgorithms::Forking::BEGIN@28 |
29 | 2 | 19µs | 1 | 4µs | # spent 4µs within Foswiki::Store::SearchAlgorithms::Forking::BEGIN@29 which was called:
# once (4µs+0s) by Foswiki::Store::Rcs::Store::query at line 29 # spent 4µs making 1 call to Foswiki::Store::SearchAlgorithms::Forking::BEGIN@29 |
30 | 2 | 18µs | 1 | 4µs | # spent 4µs within Foswiki::Store::SearchAlgorithms::Forking::BEGIN@30 which was called:
# once (4µs+0s) by Foswiki::Store::Rcs::Store::query at line 30 # spent 4µs making 1 call to Foswiki::Store::SearchAlgorithms::Forking::BEGIN@30 |
31 | 2 | 18µs | 1 | 3µs | # spent 3µs within Foswiki::Store::SearchAlgorithms::Forking::BEGIN@31 which was called:
# once (3µs+0s) by Foswiki::Store::Rcs::Store::query at line 31 # spent 3µs making 1 call to Foswiki::Store::SearchAlgorithms::Forking::BEGIN@31 |
32 | 2 | 22µs | 1 | 3µs | # spent 3µs within Foswiki::Store::SearchAlgorithms::Forking::BEGIN@32 which was called:
# once (3µs+0s) by Foswiki::Store::Rcs::Store::query at line 32 # spent 3µs making 1 call to Foswiki::Store::SearchAlgorithms::Forking::BEGIN@32 |
33 | |||||
34 | 2 | 56µs | 2 | 71µs | # spent 40µs (9+31) within Foswiki::Store::SearchAlgorithms::Forking::BEGIN@34 which was called:
# once (9µs+31µs) by Foswiki::Store::Rcs::Store::query at line 34 # spent 40µs making 1 call to Foswiki::Store::SearchAlgorithms::Forking::BEGIN@34
# spent 31µs making 1 call to constant::import |
35 | |||||
36 | # spent 5µs within Foswiki::Store::SearchAlgorithms::Forking::BEGIN@36 which was called:
# once (5µs+0s) by Foswiki::Store::Rcs::Store::query at line 41 | ||||
37 | 1 | 5µs | if ( $Foswiki::cfg{UseLocale} ) { | ||
38 | require locale; | ||||
39 | import locale(); | ||||
40 | } | ||||
41 | 1 | 844µs | 1 | 5µs | } # spent 5µs making 1 call to Foswiki::Store::SearchAlgorithms::Forking::BEGIN@36 |
42 | |||||
43 | =begin TML | ||||
44 | |||||
45 | ---++ ClassMethod new( $class, ) -> $cereal | ||||
46 | |||||
47 | =cut | ||||
48 | |||||
49 | # spent 31µs (23+8) within Foswiki::Store::SearchAlgorithms::Forking::new which was called:
# once (23µs+8µs) by Foswiki::Store::Rcs::Store::query at line 660 of /var/www/foswikidev/core/lib/Foswiki/Store/Rcs/Store.pm | ||||
50 | 1 | 17µs | 1 | 8µs | my $self = shift()->SUPER::new( 'SEARCH', @_ ); # spent 8µs making 1 call to Foswiki::Store::Interfaces::QueryAlgorithm::new |
51 | 1 | 4µs | return $self; | ||
52 | } | ||||
53 | |||||
54 | # Search .txt files in $dir for $searchString. This is the 'old' interface | ||||
55 | # to search algorithms (prior to Sven's massive search refactoring. It was | ||||
56 | # simply called 'search') | ||||
57 | # spent 48.8s (1.42+47.4) within Foswiki::Store::SearchAlgorithms::Forking::_search which was called 40 times, avg 1.22s/call:
# 40 times (1.42s+47.4s) by Foswiki::Store::SearchAlgorithms::Forking::_webQuery at line 248, avg 1.22s/call | ||||
58 | 40 | 53µs | my ( $searchString, $web, $inputTopicSet, $session, $options ) = @_; | ||
59 | |||||
60 | # SMELL: I18N: 'grep' must use locales if needed, | ||||
61 | # for case-insensitive searching. | ||||
62 | 40 | 27µs | my $program = ''; | ||
63 | |||||
64 | 40 | 118µs | if ( $options->{type} | ||
65 | && ( $options->{type} eq 'regex' || $options->{wordboundaries} ) ) | ||||
66 | { | ||||
67 | $program = $Foswiki::cfg{Store}{EgrepCmd}; | ||||
68 | } | ||||
69 | else { | ||||
70 | $program = $Foswiki::cfg{Store}{FgrepCmd}; | ||||
71 | } | ||||
72 | |||||
73 | 40 | 47µs | if ( $options->{casesensitive} ) { | ||
74 | 40 | 233µs | $program =~ s/%CS\{(.*?)\|.*?\}%/$1/g; | ||
75 | } | ||||
76 | else { | ||||
77 | $program =~ s/%CS\{.*?\|(.*?)\}%/$1/g; | ||||
78 | } | ||||
79 | 40 | 48µs | if ( $options->{files_without_match} ) { | ||
80 | 40 | 189µs | $program =~ s/%DET\{.*?\|(.*?)\}%/$1/g; | ||
81 | } | ||||
82 | else { | ||||
83 | $program =~ s/%DET\{(.*?)\|.*?\}%/$1/g; | ||||
84 | } | ||||
85 | 40 | 31µs | if ( $options->{wordboundaries} ) { | ||
86 | |||||
87 | # Item5529: Can't use quotemeta because $searchString may | ||||
88 | # be UTF8 encoded | ||||
89 | # TODO when testing UTF-8 code, try quotemeta. It should | ||||
90 | # work with a decent perl | ||||
91 | $searchString =~ s#([][|/\\\$\^*()+\{\};@?.\{\}])#\\$1#g; | ||||
92 | $searchString = '\b' . $searchString . '\b'; | ||||
93 | } | ||||
94 | |||||
95 | 40 | 74µs | if ( $Foswiki::cfg{DetailedOS} eq 'MSWin32' ) { | ||
96 | |||||
97 | #try to escape the ^ and "" for native windows grep and apache | ||||
98 | $searchString =~ s/\[\^/[^^/g; | ||||
99 | |||||
100 | # Fix escaping and quoting for Windows | ||||
101 | $searchString =~ s#\\#\\\\#g; | ||||
102 | $searchString =~ s#"#\\"#g; | ||||
103 | $searchString = q(") . $searchString . q("); | ||||
104 | } | ||||
105 | |||||
106 | 40 | 25µs | my $matches = ''; | ||
107 | |||||
108 | #SMELL, TODO, replace with Store call. | ||||
109 | 40 | 51µs | my $sDir = $Foswiki::cfg{DataDir} . '/' . $web . '/'; | ||
110 | |||||
111 | # process topics in sets, fix for Codev.ArgumentListIsTooLongForSearch | ||||
112 | 40 | 13µs | my $maxTopicsInSet = 512; # max number of topics for a grep call | ||
113 | # SMELL: the number is actually dependant on the length of the path | ||||
114 | # to each file | ||||
115 | # SMELL: the following while loop should probably be made by sysCommand, | ||||
116 | # as this is a leaky abstraction. | ||||
117 | # heck, on pre WinXP its only 2048, post XP its 8191 - | ||||
118 | # http://support.microsoft.com/kb/830473 | ||||
119 | 40 | 23µs | if ( $Foswiki::cfg{DetailedOS} eq 'MSWin32' ) { | ||
120 | |||||
121 | #tune the number based on the length of "$sDir/WebSearchAdvanced.txt" | ||||
122 | #30 is a guess - wotamess | ||||
123 | $maxTopicsInSet = | ||||
124 | ( ( 8191 - ( length($program) + length($searchString) + 30 ) ) / | ||||
125 | ( length("$sDir/LongWebSearchAdvanced.txt") + 10 ) ); | ||||
126 | |||||
127 | #print STDERR "++++++++++++ $maxTopicsInSet \n"; | ||||
128 | } | ||||
129 | |||||
130 | # while (my @set = splice( @take, 0, $maxTopicsInSet )) { | ||||
131 | # @set = map { "$sDir/$_.txt" } @set; | ||||
132 | 40 | 15µs | my @set; | ||
133 | 40 | 56µs | 40 | 4.25ms | $inputTopicSet->reset(); # spent 4.25ms making 40 calls to Foswiki::Iterator::FilterIterator::reset, avg 106µs/call |
134 | 40 | 84µs | 40 | 4.87ms | while ( $inputTopicSet->hasNext() ) { # spent 4.87ms making 40 calls to Foswiki::Iterator::FilterIterator::hasNext, avg 122µs/call |
135 | 46040 | 76.7ms | 46040 | 391ms | my $webtopic = $inputTopicSet->next(); # spent 391ms making 46040 calls to Foswiki::Iterator::FilterIterator::next, avg 8µs/call |
136 | 46040 | 88.9ms | 46040 | 493ms | my ( $Iweb, $tn ) = # spent 493ms making 46040 calls to Foswiki::Func::normalizeWebTopicName, avg 11µs/call |
137 | Foswiki::Func::normalizeWebTopicName( $web, $webtopic ); | ||||
138 | 46040 | 70.0ms | push( @set, "$sDir/$tn.txt" ); | ||
139 | 46040 | 182ms | 92000 | 2.09s | if ( # spent 2.09s making 92000 calls to Foswiki::Iterator::FilterIterator::hasNext, avg 23µs/call |
140 | ( $#set >= $maxTopicsInSet ) #replace with character count.. | ||||
141 | || !( $inputTopicSet->hasNext() ) | ||||
142 | ) | ||||
143 | { | ||||
144 | 120 | 2.30ms | 120 | 44.4s | my ( $m, $exit ) = Foswiki::Sandbox->sysCommand( # spent 44.4s making 120 calls to Foswiki::Sandbox::sysCommand, avg 370ms/call |
145 | $program, | ||||
146 | TOKEN => $searchString, | ||||
147 | FILES => \@set | ||||
148 | ); | ||||
149 | 120 | 14.0ms | @set = (); | ||
150 | |||||
151 | # man grep: "Normally, exit status is 0 if selected lines are found | ||||
152 | # and 1 otherwise. But the exit status is 2 if an error occurred, | ||||
153 | # unless the -q or --quiet or --silent option is used and a selected | ||||
154 | # line is found." | ||||
155 | 120 | 153µs | if ( $exit > 1 ) { | ||
156 | |||||
157 | # TODO: need to work out a way to alert the admin there is | ||||
158 | # a problem, without filling up the log files with repeated | ||||
159 | # SEARCH's | ||||
160 | |||||
161 | # NOTE: we ignore the error, because grep returns an error | ||||
162 | # if it comes across a broken file link or a file it does | ||||
163 | # not have permission to open, so throwing here gives wrong | ||||
164 | # search results. | ||||
165 | # throw Error::Simple( | ||||
166 | # "$program Grep for '$searchString' returned error") | ||||
167 | } | ||||
168 | 120 | 2.94ms | 120 | 27.6ms | $matches .= Foswiki::Store::decode($m); # spent 27.6ms making 120 calls to Foswiki::Store::decode, avg 230µs/call |
169 | } | ||||
170 | } | ||||
171 | 40 | 38µs | my %seen; | ||
172 | |||||
173 | # Note use of / and \ as dir separators, to support Winblows | ||||
174 | $matches =~ | ||||
175 | 17560 | 443ms | s/([^\/\\]*?)\.txt(:(.*))?$/push( @{$seen{$1}}, ($3||'') ); ''/gem; | ||
176 | |||||
177 | # Implicit untaint OK; data from grep | ||||
178 | |||||
179 | 40 | 872µs | return \%seen; | ||
180 | } | ||||
181 | |||||
182 | #ok, for initial validation, naively call the code with a web. | ||||
183 | # spent 49.1s (24.1ms+49.1) within Foswiki::Store::SearchAlgorithms::Forking::_webQuery which was called 40 times, avg 1.23s/call:
# 40 times (24.1ms+49.1s) by Foswiki::Store::Interfaces::QueryAlgorithm::__ANON__[/var/www/foswikidev/core/lib/Foswiki/Store/Interfaces/QueryAlgorithm.pm:119] at line 110 of /var/www/foswikidev/core/lib/Foswiki/Store/Interfaces/QueryAlgorithm.pm, avg 1.23s/call | ||||
184 | 40 | 61µs | my ( $this, $query, $web, $inputTopicSet, $session, $options ) = @_; | ||
185 | ASSERT( !$query->isEmpty() ) if DEBUG; | ||||
186 | |||||
187 | #print STDERR "ForkingSEARCH(".join(', ', @{ $query->tokens() }).")\n"; | ||||
188 | # default scope is 'text' | ||||
189 | 40 | 74µs | $options->{'scope'} = 'text' | ||
190 | unless ( defined( $options->{'scope'} ) | ||||
191 | && $options->{'scope'} =~ m/^(topic|all)$/ ); | ||||
192 | |||||
193 | 40 | 20µs | my $topicSet = $inputTopicSet; | ||
194 | 40 | 16µs | if ( !defined($topicSet) ) { | ||
195 | |||||
196 | #then we start with the whole web | ||||
197 | #TODO: i'm sure that is a flawed assumption | ||||
198 | my $webObject = Foswiki::Meta->new( $session, $web ); | ||||
199 | $topicSet = | ||||
200 | Foswiki::Search::InfoCache::getTopicListIterator( $webObject, | ||||
201 | $options ); | ||||
202 | } | ||||
203 | ASSERT( UNIVERSAL::isa( $topicSet, 'Foswiki::Iterator' ) ) if DEBUG; | ||||
204 | |||||
205 | #print STDERR "######## Forking search ($web) tokens " | ||||
206 | # .scalar(@{$query->tokens()})." : ".join(',', @{$query->tokens()})."\n"; | ||||
207 | # AND search - search once for each token, ANDing result together | ||||
208 | 40 | 196µs | 40 | 120µs | foreach my $token ( @{ $query->tokens() } ) { # spent 120µs making 40 calls to Foswiki::Search::Node::tokens, avg 3µs/call |
209 | |||||
210 | 40 | 21µs | my $tokenCopy = $token; | ||
211 | |||||
212 | # flag for AND NOT search | ||||
213 | 40 | 22µs | my $invertSearch = 0; | ||
214 | 40 | 34µs | $invertSearch = ( $tokenCopy =~ s/^\!// ); | ||
215 | |||||
216 | # scope can be 'topic' (default), 'text' or "all" | ||||
217 | # scope='topic', e.g. Perl search on topic name: | ||||
218 | 40 | 13µs | my %topicMatches; | ||
219 | 40 | 36µs | unless ( $options->{'scope'} eq 'text' ) { | ||
220 | my $qtoken = $tokenCopy; | ||||
221 | |||||
222 | # FIXME I18N | ||||
223 | # http://foswiki.org/Tasks/Item1646 this causes us to use/leak huge amounts of memory if called too often | ||||
224 | $qtoken = quotemeta($qtoken) if ( $options->{'type'} ne 'regex' ); | ||||
225 | |||||
226 | $topicSet->reset(); | ||||
227 | while ( $topicSet->hasNext() ) { | ||||
228 | my $webtopic = $topicSet->next(); | ||||
229 | my ( $itrWeb, $topic ) = | ||||
230 | Foswiki::Func::normalizeWebTopicName( $web, $webtopic ); | ||||
231 | |||||
232 | if ( $options->{'casesensitive'} ) { | ||||
233 | |||||
234 | # fix for Codev.SearchWithNoPipe | ||||
235 | #push(@scopeTopicList, $topic) if ( $topic =~ m/$qtoken/ ); | ||||
236 | $topicMatches{$topic} = 1 if ( $topic =~ m/$qtoken/ ); | ||||
237 | } | ||||
238 | else { | ||||
239 | |||||
240 | #push(@scopeTopicList, $topic) if ( $topic =~ m/$qtoken/i ); | ||||
241 | $topicMatches{$topic} = 1 if ( $topic =~ m/$qtoken/i ); | ||||
242 | } | ||||
243 | } | ||||
244 | } | ||||
245 | |||||
246 | # scope='text', e.g. grep search on topic text: | ||||
247 | 40 | 1.10ms | unless ( $options->{'scope'} eq 'topic' ) { | ||
248 | 40 | 188µs | 40 | 48.8s | my $textMatches = # spent 48.8s making 40 calls to Foswiki::Store::SearchAlgorithms::Forking::_search, avg 1.22s/call |
249 | _search( $tokenCopy, $web, $topicSet, $session, $options ); | ||||
250 | |||||
251 | #bring the text matches into the topicMatch hash | ||||
252 | 40 | 13.3ms | if ($textMatches) { | ||
253 | @topicMatches{ keys %$textMatches } = values %$textMatches; | ||||
254 | } | ||||
255 | } | ||||
256 | |||||
257 | 40 | 131µs | my @scopeTextList = (); | ||
258 | 40 | 435µs | if ($invertSearch) { | ||
259 | $topicSet->reset(); | ||||
260 | while ( $topicSet->hasNext() ) { | ||||
261 | my $webtopic = $topicSet->next(); | ||||
262 | my ( $Iweb, $topic ) = | ||||
263 | Foswiki::Func::normalizeWebTopicName( $web, $webtopic ); | ||||
264 | |||||
265 | if ( $topicMatches{$topic} ) { | ||||
266 | } | ||||
267 | else { | ||||
268 | push( @scopeTextList, $topic ); | ||||
269 | } | ||||
270 | } | ||||
271 | } | ||||
272 | else { | ||||
273 | |||||
274 | #TODO: the sad thing about this is we lose info | ||||
275 | 40 | 3.35ms | @scopeTextList = keys(%topicMatches); | ||
276 | } | ||||
277 | |||||
278 | # reduced topic list for next token | ||||
279 | 40 | 4.56ms | 40 | 218ms | $topicSet = # spent 218ms making 40 calls to Foswiki::Search::InfoCache::new, avg 5.45ms/call |
280 | Foswiki::Search::InfoCache->new( $Foswiki::Plugins::SESSION, $web, | ||||
281 | \@scopeTextList ); | ||||
282 | } | ||||
283 | |||||
284 | 40 | 484µs | return $topicSet; | ||
285 | } | ||||
286 | |||||
287 | 1 | 3µs | 1; | ||
288 | __END__ |