[Mono-dev] ToString() performace in Mono

Atsushi Eno atsushi at ximian.com
Thu Dec 13 11:16:33 EST 2007


Hello,

What is the status for the patch ("the patch" I mean, from Kazuki) ?

I'm not sure what Andreas is trying to change (a patch would be
more persuasive) but my understanding is that it does not conflict
with the patch.

If no objection, I'll test the patch and check it in svn.

Atsushi Eno


Andreas Nahr wrote:
> The following code (add to NumberFormatter) and redirect the ToStrings
> improves performance even more:
> 
> Old Formatter: 1266
> New Formatter with negative number: 953
> New Formatter with positive number: 750
> 
> Tested on Windows XP, Mono 1.2.5
> 
> 		internal static string FormatInteger (ref NumberStore ns)
> 		{
> 			// Add one additional char for default sign, one for
> potential 0-padding
> 			StringBuilder cb = new StringBuilder
> (ns.IntegerDigits + 2);
> 
> 			if (!ns.Positive && !ns.CheckZeroOnlyInteger ())
> 				cb.Append
> (NumberFormatInfo.CurrentInfo.NegativeSign);
> 
> 			ns.AppendIntegerString (ns.IntegerDigits > 0 ?
> ns.IntegerDigits : 1, cb);
> 			return cb.ToString ();
> 		}
> 
> The additional performance in Comparison to Kazuki Oikawa suggestion is
> mainly gained through not retrieving NumberFormatInfo.CurrentInfo in cases
> where it's not needed (and other small things like ref struct).
> NumberFormatInfo.CurrentInfo should be optimized anyways. It just shouldn't
> be as slow as it is as it is likely used in other situations, too.
> 
> Greetings
> Andreas
> 
> -----Ursprüngliche Nachricht-----
> Von: mono-devel-list-bounces at lists.ximian.com
> [mailto:mono-devel-list-bounces at lists.ximian.com] Im Auftrag von Kazuki
> Oikawa
> Gesendet: Samstag, 24. November 2007 06:02
> An: pablosantosluac
> Cc: mono-devel-list at lists.ximian.com
> Betreff: Re: [Mono-dev] ToString() performace in Mono
> 
> Hi.
> 
> This patch improves ToString performance (30% faster).
> 
> Running on Opteron 270 (2GHz), Gentoo Linux 2007.0 x86_64 $ mono hoge.exe
> val is 5999999 and time 7008 (before) $ mono hoge.exe val is 5999999 and
> time 5078 (after)
> 
> Current code is use "G" format but this equals "D" format when precision is
> not defined and value is integer.
> 
> Best regards.
> 
> --
> Kazuki Oikawa
> 
> 
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
> 




More information about the Mono-devel-list mailing list