Faster dictionaries?

sig siguctua at gmail.com
Thu Jul 19 20:53:57 UTC 2007


On 19/07/07, Andres Valloud <AVALLOUD at roadrunner.com> wrote:
> sig wrote:
> > look at MaDictionary class comment.
> >
> > both dictionaries used in comparison tests populated simply using just:
> >
> > obj := Object new.
> > dict at: obj put: obj.
> I don't have a Squeak image handy right now, but I'd suggest checking
> these cases out...
>
> Time it takes to add all strings in the image to a dictionary.
>
> Time it takes to add all symbols in the image to a dictionary.

for symbols:

time to add all strings to bd: 467
time to add all strings to sd: 998

>
> Time it takes to add 100k consecutive integers as keys of a dictionary.
>
| sd md r |
Transcript clear.
r := OrderedCollection new.
1 to: 100000 do: [:each | r add: each ].
sd := BDictionary new.
Smalltalk garbageCollect.
Transcript cr; show: 'time to add all strings to bd: ',
	[ r do: [:each | sd at: each put: each ] ] timeToRun printString.
sd := Dictionary new.
Smalltalk garbageCollect.
Transcript cr; show: 'time to add all strings to sd: ',
	[ r do: [:each | sd at: each put: each ] ] timeToRun printString.


time to add all strings to bd: 719
time to add all strings to sd: 870


| sd md r |
Transcript clear.
r := OrderedCollection new.
1 to: 100000 do: [:each | r add: each ].
sd := IdentityBDictionary new.
Smalltalk garbageCollect.
Transcript cr; show: 'time to add all strings to bd: ',
	[ r do: [:each | sd at: each put: each ] ] timeToRun printString.
sd := IdentityDictionary new.
Smalltalk garbageCollect.
Transcript cr; show: 'time to add all strings to sd: ',
	[ r do: [:each | sd at: each put: each ] ] timeToRun printString.

time to add all strings to bd: 719
time to add all strings to sd: 1580


> Thanks,
> Andres.
>
>
>



More information about the Squeak-dev mailing list