Writing a large Collection of integers to a file fast
me at zulq.net
Mon Jan 28 12:38:53 UTC 2008
David T. Lewis wrote:
> The #reversed is not unnecessary. Other algorithms are of course
> possible, but this one is not wrong.
It is the creation of an intermediate string that is unnecessary. The
#printOn:base: is passed a stream on which it can print directly.
I mentioned the reverse because it was another (the third) iteration of
the integers digits (create, reverse and print). In fact, a negative
number requires another iteration.
> It would be best not to open a new Mantis entry unless there actually
> is a new issue to be resolved.
There is a "tweak" severity that suits this I think.
The change yields an ~ 18% improvement when hooked up to
#printStringBase: in this benchmark:
[-1000000 to: 1000000 do: [:i | i asString]]
There are also significantly less objects produced.
This may be very little in practicality but the only way to know that is
to measure it.
More information about the Squeak-dev