[Mono-dev] Further improvements to toString performance

Eyal Alaluf eyala at mainsoft.com
Thu Mar 20 05:46:18 EDT 2008

Hi, all.

The attached patch contains further improvements to the perf or ToString
of primitive types.
The perf gain is due to two changes
  1. An instance of NumberFormatter is placed as a member of the Thread
class. This allows reuse of the character array within the NumberFormat
class and to cache the lookup of the NumberFormatInfo from the current
culture which turns out to be a costly operation.
  2. The default ToString of integers has been specialized (because of
its simplicity).
The results of these improvements are:
  10,000,000 * 12345.ToString():    From 13.0 Secs to 6.3 Secs
  10,000,000 * 12345.ToString("G"): From 14.7 Secs to 8.4 Secs
  10,000,000 * 0.12345.ToString():  From 27.9 Secs to 21.3 Secs
The results were made on my (a bit outdated) PC but the same
improvements were seen in newer types of machines.
I have also added the copyright and license notice.
Your comments are welcome.

Thanks, Eyal.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ToString.diff2
Type: application/octet-stream
Size: 46044 bytes
Desc: ToString.diff2
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20080320/6d130180/attachment-0001.obj 

More information about the Mono-devel-list mailing list