[Mono-dev] [PATCH] Further improvements to toString performance

Miguel de Icaza miguel at novell.com
Thu Mar 27 11:46:49 EDT 2008


Hello Eyal,

     I have done a cursory review of this patch, and it looks good to
go.    Doing it now, will give it more exposure to people.


On Tue, 2008-03-25 at 06:05 -0700, Eyal Alaluf wrote:
> Hi, Miguel.
> 
> 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.
> 
> Waiting for your approval, Eyal.


More information about the Mono-devel-list mailing list