Strange performance artifacts

Dan Ingalls DanI at
Sat Aug 15 17:15:46 UTC 1998

Daniel -

>I've created a new method for point, allowing it's the rotation about the origin using multiplication as a complex number,
>as it seemed a reasonably fast way of rotating a single point around a full circle in small fixed increments.
>Then I wanted to time it. I don't have the code used here/now, but I used to variations like -
>A) Time millisecondsToRun: [ firstPoint transformBy: rotationPoint].
>B) Time millisecondsToRun: [ firstPoint _ firstPoint transformBy: rotationPoint].
>Now, B was gratifyingly faster than the code I'd used earlier (by some 30%, and much more amenable to going primitive).
>But what cought my eye and got me very perplexed was that A was around twice as *slow* as B.
>That is to say, for some reason the added assignment made code much faster. (?!?!?!).
>Ideas why this might be anyone?

My first conjecture is that you are below the resolution of the millisecond clock.

I would try...

A) Time millisecondsToRun: [1 to: 1000 do: [:i | firstPoint transformBy: rotationPoint]].
B) Time millisecondsToRun: [1 to: 1000 do: [:i |  ignored _ firstPoint transformBy: rotationPoint]].

More information about the Squeak-dev mailing list