[Pkg] The Trunk: Collections-eem.717.mcz

commits at source.squeak.org commits at source.squeak.org
Thu Oct 13 23:14:52 UTC 2016


Eliot Miranda uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-eem.717.mcz

==================== Summary ====================

Name: Collections-eem.717
Author: eem
Time: 13 October 2016, 4:14:34.323953 pm
UUID: ff6f9273-5077-47f9-b660-0cdd4b184bb1
Ancestors: Collections-dtl.716

Revise upwards the cross-over in SequenceableCollection>>atAllPut: at which point to move from a simple loop using at:put: to connivance using replaceFrom:to:with:startingAt:.  Add a comment that includes the code to actually test this, instead of simply claiming without support.

=============== Diff against Collections-dtl.716 ===============

Item was changed:
  ----- Method: SequenceableCollection>>atAllPut: (in category 'accessing') -----
  atAllPut: anObject 
  	"Put anObject at every one of the receiver's indices."
  
  	| size |
+ 	(size := self size) > 50 "first method faster for larger sizes; see below"
- 	(size := self size) > 26 "first method faster from 27 accesses and on"
  		ifTrue: [self from: 1 to: size put: anObject]
+ 		ifFalse: [1 to: size do: [:index | self at: index put: anObject]]
+ 
+ 	"Here's code to test what's a good cross over."
+ 	"(1 to: 3) collect:
+ 		[:j|
+ 		{ Array. ByteArray. FloatArray. WordArray } collect:
+ 			[:class| | a e |
+ 			a := class new: 250.
+ 			e := a at: 1.
+ 			(1 to: a size) detect:
+ 				[:n| | t1 t2 |
+ 				t1 := [1 to: 1000 do: [:i| a from: 1 to: n put: e]] timeToRun.
+ 				t2 := [1 to: 1000 do: [:i| 1 to: n do: [:index | a at: index put: e]]] timeToRun.
+ 				t1 < t2]]]"
+ 	"32-bit Spur x86 #(#(69 54 9 63) #(64 52 10 55) #(63 53 9 61))"
+ 	"64-bit Spur x86-64 #(#(63 50 10 55) #(60 48 10 54) #(63 44 9 50))"!
- 		ifFalse: [1 to: size do: [:index | self at: index put: anObject]]!



More information about the Packages mailing list