Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Issue: Collection.Clear(), I don't find it.
Message
 
À
13/05/2005 06:17:38
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Versions des environnements
Visual FoxPro:
VFP 9
Divers
Thread ID:
01013756
Message ID:
01014112
Vues:
22
>Why?

Fabio, I always used createobject("Collection") when I wanted to re-use a collection, for I found it was faster, do you see any problem with it?

I adapted your array example and for me it is 20% faster, but maybe I am missing something.
clear
lnLen = 100000
el=SET("Eventlist")

SET EVENTLIST TO init,Destroy
SET EVENTTRACKING TO SYS(2023)+'\track.log'
SET EVENTTRACKING ON

lnStart=Seconds()
loCollection = Createobject("collection")
FOR k=1 TO lnLen
	loCollection.Add(CREATEOBJECT("Exception"), 'C1_'+TRANSFORM(m.k))
NEXT
lnStart=Seconds()
loCollection.Remove(-1)
? 'Remove: ', Seconds() - lnStart
release loCollection

loCollection = Createobject("collection")
FOR k=1 TO lnLen
	loCollection.Add(CREATEOBJECT("Exception"), 'C2_'+TRANSFORM(m.k))
NEXT
lnStart=Seconds()
loCollection = Createobject("collection")
? 'Create: ', Seconds() - lnStart
release loCollection

SET EVENTTRACKING OFF
SET EVENTTRACKING TO 
SET EVENTLIST TO &el

MODIFY FILE SYS(2023)+'\track.log'
ERASE SYS(2023)+'\track.log'
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?

"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare

"To die for a religion is easier than to live it absolutely"
Jorge L. Borges
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform