To observe speed improvements in code, make sure you establish a stable baseline time. Getting a stable execution time for Smalltalk code using Time millisecondsToRun: [...] is a difficult task because raw time can vary dramatically depending on the initial and current state of the virtual machine. For example, the garbage collector may scavenge more often or longer in one run than in another. This can give the appearance of improvement or degradation when no code has changed.To be unobtrusive, the Stats tool allocates the memory it needs before it runs and creates as little garbage as possible while it runs. Large allocation requests do not occur between runs. The Stats tool does not mask how the application uses memory.The following menu items in the Bench menu are used to control the stability of raw execution time for a bench method:Other factors affecting the stability of a benchmark must be considered when establishing a baseline. The following factors are beyond the control of the Stats tool and may cause execution time to vary:
|