Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Issue: Collection.Clear(), I don't find it.
Message
 
To
13/05/2005 06:17:38
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Environment versions
Visual FoxPro:
VFP 9
Miscellaneous
Thread ID:
01013756
Message ID:
01014112
Views:
21
>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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform