[squeak-dev] Very slow copy/ primitives

karl ramberg karlramberg at gmail.com
Wed Mar 1 21:23:50 UTC 2023


Hi
Mines game got really sluggish on a old laptop with i3 processor.
I tracked it down to this method where we copy protoTile instance variable

MineBoard>>adjustTiles
"reset tiles"

| newSubmorphs count r c |

submorphs do: "clear out all of the tiles."
[:m | m privateOwner: nil].

newSubmorphs := OrderedCollection new.

r := 0.
c := 0.
count := columns * rows.

1 to: count do:
[:m |
newSubmorphs add:
(protoTile copy *"Change this to MinesTile new to speed up"*
position: self position + (self protoTile extent * (c @ r));
actionSelector: #tileClickedAt:newSelection:modifier:;
arguments: (Array with: (c+1) @ (r+1));
target: self;
privateOwner: self).
c := c + 1.
c >= columns ifTrue: [c := 0. r := r + 1]].
submorphs := newSubmorphs asArray.


Here is MessageTally:

[                        67.5% {8826ms} MinesBoard>>adjustTiles
[                          67.5% {8824ms} MinesTile(Morph)>>copy
[                            67.5% {8824ms} MinesTile(Object)>>veryDeepCopy
[                              66.6% {8713ms} DeepCopier>>fixDependents
[                                66.6% {8713ms}
WeakIdentityKeyDictionary(WeakKeyDictionary)>>associationsDo:
[                                  64.3% {8404ms} primitives
[                                  2.2% {289ms} [] DeepCopier>>fixDependents
[                                    1.7% {222ms} DependentsArray>>do:
[                                      1.1% {139ms} primitives

Best,
Karl
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20230301/adc29ebe/attachment.html>


More information about the Squeak-dev mailing list