Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Which is faster: array or cursor?
Message
De
10/03/2009 13:12:58
 
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:
01386943
Vues:
104
>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?

I did some testing on this last year. Here's a paragraph from my Southwest Fox session notes:

What about arrays? Is a cursor a better choice than an array for storing a small to moderate amount of data? From a speed perspective, it depends what you want to do with the data. I tested with data sets of four columns and ranging from 10 rows to 10,010. The first test was creating and populating the array or cursor. In this test, arrays seems to be about a third faster. My second test looped through the array and the cursor. Looping through the cursor was faster, but not enough to matter. (I also did this test with a single column of data; in that case, looping the array was faster.) Finally, I tested searching for data in each case. Here, the cursor was a clear winner. For larger data sets, SEEKing in a cursor was an order of magnitude faster than searching in an array with ASCAN(). The cursor’s advantage was even bigger when the search item wasn’t in the data set. For 10,010 items, searching for a non-existent item in an array took 50 times as long as SEEKing the same non-existent item in a cursor.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform