Here's one more optimization, which keeps the indexing array in memory for subsequent searches. Note that this will run extra fast every time after the first run, even if you change the search text- it only reindexes when you change the target text. With this one, Check Matches runs in under 200ms after the first run on my 500Mhz iBook =). Judging from previous benchmarks, that should mean < 100ms on your end.
on mouseUp global tMatch,tMatchHash
set cursor to watch put the milliseconds into sMS put "./TargetText.txt" into fn open file fn read from file fn until EOF put it into tMatchList close file fn put "./SearchTextList.txt" into fn open file fn read from file fn until EOF put it into stList close file fn put timeit(sMS,"Load Data") into sMS put empty into field "TheResults" -- stripping quotes from both sets saves problems with single quotes -- or with quoted strings being treated as a word replace quote with empty in stList
if (md5Digest(tMatchList) = tMatchHash) then
else
put md5Digest(tMatchList) into tMatchHash
replace quote with empty in tMatchList
-- Prepare the target text in all consecutive triplet groups
put empty into k1
put empty into k2
repeat for each word inWord in tMatchList
put k2 into k1
put k3 into k2
put inWord into k3
put true into tMatch[k1 && k2 && k3]
end repeat
end if repeat for each line inLine in stList
if the number of words of inLine = 3 then
put true into tSearch[inLine]
else
-- Do a simple search for groups other than three words
if inLine is in tMatchList then
put inLine & return after MatchList
end if
end if
end repeat
-- Now for the Revolution!
put it into fld "SearchTextList"
intersect tSearch with tMatch
put keys(tSearch) & cr & MatchList into Matches
put timeit(sMS,"Check Matches") into sMS
put Matches into field "TheResults"
put stList into field "SearchTextList"
put tMatchList into field "TargetText"
put timeit(sMS,"Display All") into sMS
end mouseUpIt made sense to start using real data: a 120,000-word target file, and a list of 915 search strings. Those are now available with the updated projects here: http://www.yav.com/speed.html Another new feature is that I divided the task into 3 segments (Load Data, Check Matches, Display Data). The latest results follow. Revolution is currently running this particular task THREE TIMES FASTER than RealBasic, and more than TWELVE TIMES FASTER than SuperCard.
Chris Yavelow
Revolution (2.2) -- Total = 1,118 ms Load data = 19 ms Check Matches = 821 ms Display All = 278 ms
RealBasic (5.5.1) -- Total = 3,189 ms Load data = 608 ms Check Matches = 833 ms Display All = 1748 ms
SuperCard (4.1.2) -- Total = 13,472 ms Load data = 0 ms Check Matches = 11952 ms Display All = 1520 ms _______________________________________________ use-revolution mailing list [EMAIL PROTECTED] http://lists.runrev.com/mailman/listinfo/use-revolution
_______________________________________________ use-revolution mailing list [EMAIL PROTECTED] http://lists.runrev.com/mailman/listinfo/use-revolution
