Hi All, Some time ago Paolo did post a message to see if we could change the rng because will fast it was making garbage.
Thus Paolo did suggest to implement the Mersenne Twister. So here you can find an implementation of it: rev: c0a83d2 https://github.com/mathk/smalltalk/commit/c0a83d2 a1f137b https://github.com/mathk/smalltalk/commit/a1f137b ab8cc96 https://github.com/mathk/smalltalk/commit/ab8cc96 ed9360a https://github.com/mathk/smalltalk/commit/ed9360a For the time being I did a separate class namely RandomMT19937. only the #next differ from the original Random class. Now #next return a positive SmallInteger (30bit wise) so no object are allocated on 32bit and 64bit arch. I have made a tiny bench: ma...@nani smalltalk $ cat BenchRand.st Eval [ | n k r o | r := RandomMT19937 source. n := 100000. k := 500. o := OrderedCollection new. 1 to: n do: [:x | ((r between: 0 and: (n := n - 1)) < k ifTrue: [o add: x. k := k - 1]) notNil ]. ] ma...@nani smalltalk $ time gst BenchRand.st real 0m0.096s user 0m0.072s sys 0m0.012s ma...@nani smalltalk $ cat BenchRand.st Eval [ | n k r o | r := Random source. n := 100000. k := 500. o := OrderedCollection new. 1 to: n do: [:x | ((r between: 0 and: (n := n - 1)) < k ifTrue: [o add: x. k := k - 1]) notNil ]. ] ma...@nani smalltalk $ time gst BenchRand.st "Global garbage collection... done" real 0m0.308s user 0m0.276s sys 0m0.022s ma...@nani smalltalk $ Questions or comments are welcome. Thanks Mth __________________________________________________ Do You Yahoo!? En finir avec le spam? Yahoo! Mail vous offre la meilleure protection possible contre les messages non sollicités http://mail.yahoo.fr Yahoo! Mail _______________________________________________ help-smalltalk mailing list [email protected] http://lists.gnu.org/mailman/listinfo/help-smalltalk
