Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Google-like queries in FoxPro apps
Message
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00624182
Message ID:
00624396
Vues:
16
Claude,

The timing differences quoted in those messages appear to be mostly caused by the effects of disk caching.

I ran some more controlled tests tonight. The code took 70 Wiki topics and replicated the data until the memo file size was 8mb so there were 2080 records to test. Two copies were made, one where the memo content was all lower()'d and the other where the content was all upper()'d. The test code is listed below, it runs the search battery against all three tables 5 times per test.

My conclusions from the test:

1) The first raw scan of the tables takes on the order of 100 times as long as the subsequent scans. I think this is the reason for the differences in the messages on the West-Wind board. Subsequent scans run with negligible differences.

2) $, AT() and ATC() all perform at relatively the same rate, within a cople of percent of each other. $ being the fastest, then AT() then ATC() being only slightly slower.

3) $, AT() and ATC() their return faster if the string is found near the beginning of the string, slower if it's near the end and slowest if it's not found at all.

4) Using lower() or upper() on the second argument to both at() and atc() or on the right operand of the $ decreases performance by 30% if the search string is at the end, and 600% if the search string is at the start. This is because the whole string needs to be changed before the search occurs.
close data all

set decimals to 5
create table memosearch ( cTable c(20), cRoutine c(20), cNotes c(32), iIteration i, nTime n(7,5))

private gcTable, gnIterations
gnItertions = 5

BenchMark( "wikitopics" )
BenchMark( "lwikitopics" )
BenchMark( "uwikitopics" )

function BenchMark( pcTable )

if ( ! used( (pcTable) ) )
   use (pcTable) in 0
endif
select (pcTable)
gcTable = alias()

Iterate( "scan1", "", "raw scan" )

IterateAll( "<wiki", "at front" )
IterateAll( "</wiki", "at end" )
IterateAll( "property", "some hits" )
IterateAll( "thiswillnotbefound", "no hits" )

select cTable, cRoutine, cNotes, avg(nTime), min(nTime), max(nTime) ;
   from memosearch ;
   into cursor results ;
   group by 1,2,3 ;
   order by 3,2,1

return

function IterateAll( pcSearchText, pcNotes )
Iterate( "at1", pcSearchText, pcNotes )
Iterate( "atc1", pcSearchText, pcNotes )
Iterate( "dollar1", pcSearchText, pcNotes )

Iterate( "at1L", pcSearchText, pcNotes )
Iterate( "atc1L", pcSearchText, pcNotes )
Iterate( "dollar1L", pcSearchText, pcNotes )

Iterate( "at1U", pcSearchText, pcNotes )
Iterate( "atc1U", pcSearchText, pcNotes )
Iterate( "dollar1U", pcSearchText, pcNotes )
return

function Iterate( pcRoutine, pcSearchText, pcNotes )
local i, lnStart
for i = 1 to gnIterations
   lnStart = seconds()
   do (pcRoutine) with pcSearchText
   lnStart = seconds() - lnStart
   insert into memosearch values ( gcTable, pcRoutine, pcNotes + ":" + pcSearchText, i, lnStart )
endfor
return

function Scan1( pcJunk )
local lcX
scan
   lcX = mTopic
endscan
return

function At1( pcSearchText )
local i
scan
   i = at( pcSearchText, mTopic )
endscan
return

function AtC1( pcSearchText )
local i
scan
   i = atc( pcSearchText, mTopic )
endscan
return

function Dollar1( pcSearchText )
local i
scan
   i = pcSearchText $ mTopic
endscan
return

function At1L( pcSearchText )
local i
pcSearchText = lower( pcSearchText )
scan
   i = at( pcSearchText, lower( mTopic ) )
endscan
return

function AtC1L( pcSearchText )
local i
pcSearchText = lower( pcSearchText )
scan
   i = atc( pcSearchText, lower( mTopic ) )
endscan
return

function Dollar1L( pcSearchText )
local i
pcSearchText = lower( pcSearchText )
scan
   i = pcSearchText $ lower( mTopic )
endscan
return

function At1U( pcSearchText )
local i
pcSearchText = upper( pcSearchText )
scan
   i = at( pcSearchText, upper( mTopic ) )
endscan
return

function AtC1U( pcSearchText )
local i
pcSearchText = upper( pcSearchText )
scan
   i = atc( pcSearchText, upper( mTopic ) )
endscan
return

function Dollar1U( pcSearchText )
local i
pcSearchText = upper( pcSearchText )
scan
   i = pcSearchText $ upper( mTopic )
endscan
return
>I'm using it based on what others have seen. Check out:
>http://www.west-wind.com/wwthreads/ShowMsg.wwt?MsgId=03P0U53DC
>and for a test that was done with VFP 6:
>http://www.west-wind.com/wwthreads/ShowMsg.wwt?MsgId=03S0INFBF
>VFP 7 may have made it more consistent...
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform