Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Which is faster: array or cursor?
Message
De
09/03/2009 16:30:18
Walter Meester
HoogkarspelPays-Bas
 
 
À
09/03/2009 16:10:54
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Divers
Thread ID:
01386748
Message ID:
01386772
Vues:
117
Using this exact same code, cursor was 3 seconds slower than using an array on my dual core machine



>Cursor is fastest in my quick benchmark (by 3 seconds on 100,000 iterations), but I have to loop at least 10,000 times to see any significant difference between the 2 methods. For your 1,000 records, any way would take about the same time.
CLEAR
>
>LOCAL ARRAY laTest [1000]
>
>CREATE CURSOR Test (Test I)
>
>FOR I = 1 TO 1000
>	laTest[I] = I
>	INSERT INTO Test VALUES (I)
>ENDFOR
>
>? "Array"
>? DATETIME()
>
>FOR J = 1 TO 100000
>	FOR I = 1 TO 1000
>		I = laTest[I]
>	ENDFOR
>ENDFOR
>
>? DATETIME()
>
>? "Cursor"
>? DATETIME()
>
>FOR J = 1 TO 100000
>	SCAN
>		I = Test.Test
>	ENDSCAN
>ENDFOR
>
>? DATETIME()
>If I had 1000 values that I need to loop through (visit every node sequentially, not skip around) that needed very fast processing and they do not need disk storage... which would be faster... an array or a cursor?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform