Mantis - Squeak
Viewing Issue Advanced Details
7242 Collections trivial always 12-08-08 16:19 02-06-11 23:48
Keith_Hodges  
andreas  
low  
closed 3.10.2  
fixed  
none    
none 4.1  
0007242: Add Inplace Sort to OrderedCollection
Some basic benchmarking shows inplace sort is 5-10% faster than asSortedCollection
tests := {

[:in | in do: [ :ea | ea asSortedCollection ] ].
[:in | in do: [ :ea | ea asSortedCollection asOrderedCollection ] ].
[:in | in do: [ :ea | ea sort ] ].

}.

array := (1 to: 10000) collect: [ :ea | 1000 atRandom ].
fixture := (1 to: 100) asArray collect: [ :ea | array copy ].

tests collect: [ :test | [ test value: fixture ] timeToRun ]

 #(3666 4032 3692)

array := Symbol allSubInstances asArray.
fixture := (1 to: 100) asOrderedCollection collect: [ :ea | array copy ].

tests collect: [ :test | [ test value: fixture ] timeToRun ]

#(40257 40528 38598)

38598/40257 *100.0 = 95.8789775691184

array := (1 to: 50) collect: [ :ea | 1000 atRandom ].
fixture := (1 to: 10000) asArray collect: [ :ea | array copy ].

tests collect: [ :test | [ test value: fixture ] timeToRun ]

 #(959 1144 865)

865/959 * 100.0 = 90.1981230448384

array := (1 to: 10) collect: [ :ea | 1000 atRandom ].
fixture := (1 to: 10000) asArray collect: [ :ea | array copy ].

tests collect: [ :test | [ test value: fixture ] timeToRun ]

 #(180 252 161)
 M7242-Move sort up to SequencableCollection.1.cs [^] (7,399 bytes) 12-08-08 16:35

Notes
(0012837)
Keith_Hodges   
12-08-08 16:35   
"fix begin"
Installer mantis bug: 7242 fix: 'M7242-Move sort up to SequencableCollection.1.cs'.
"fix end"

(0013909)
leves   
11-07-10 02:24   
This was fixed in Squeak 4.1, though the sort algorithm is not in-place as the summary suggests, but it modifies the receiver if possible.