[Mono-dev] ToString() performace in Mono

pablosantosluac pablosantosluac at terra.es
Thu Nov 22 06:13:54 EST 2007


Hi,

Ok, but I'm not doing string "concat" but just converting to string, and 
using StringBuilder in this scenario, it isn't faster, as you have just 
pointed to...

My point is that ToString is about 3 times slower in Mono than its .NET 
counterpart. We'll try to get rid of it as much as we can, but some 
optimization would be really great.

Thanks,

pablo


----- Original Message ----- 
From: "Petit Eric" <surfzoid at gmail.com>
To: "pablosantosluac" <pablosantosluac at terra.es>
Cc: <mono-devel-list at lists.ximian.com>
Sent: Thursday, November 22, 2007 11:56 AM
Subject: Re: [Mono-dev] ToString() performace in Mono


> Windows and String
> val is 5999999 and time 4391
>
> Windows and StringBuilder
> val is 5999999 and time 5688
>
> Code For StringBuilder :
>
> using System;
> using System.Collections.Generic;
> using System.Text;
>
> namespace compareCompare
> {
>    class Program
>    {
>        static void Main(string[] args)
>        {
>            int ini = Environment.TickCount;
>
>            System.Text.StringBuilder k = new System.Text.StringBuilder();
>
>            for (int i = 0; i < 6000000; ++i)
>            {
>                k = new System.Text.StringBuilder(i.ToString());
>            }
>
>            Console.WriteLine("val is {0} and time {1}", k,
> Environment.TickCount - ini);
>
>            while (true)
>            {
>                if (Console.ReadKey() != null) break;
>            }
>
>        }
>    }
> }
>
>
>
>
> 2007/11/22, pablosantosluac <pablosantosluac at terra.es>:
>> Anyway, how would you use it in the sample I attached to improve
>> performance? I need to convert a different integer each pass...
>> ----- Original Message -----
>> From: "Petit Eric" <surfzoid at gmail.com>
>> To: "pablosantosluac" <pablosantosluac at terra.es>
>> Cc: <mono-devel-list at lists.ximian.com>
>> Sent: Thursday, November 22, 2007 10:24 AM
>> Subject: Re: [Mono-dev] ToString() performace in Mono
>>
>>
>> > Do you try to replace String by a System.Text.StringBuilder ?
>> >
>> > 2007/11/22, pablosantosluac <pablosantosluac at terra.es>:
>> >> Hi,
>> >>
>> >>
>> >> I've detected a performance hit on "plastic server" running on mono. I
>> >> was
>> >> actually shocked because when I checked something similar working with
>> >> integers, Mono was actually faster than .NET. But it seems it is not 
>> >> the
>> >> case with strings.
>> >>
>> >> Please consider the following code sample:
>> >>
>> >>
>> >> using System;
>> >>
>> >> namespace compareCompare
>> >> {
>> >>     class Class1
>> >>     {
>> >>         static void Main(string[] args)
>> >>         {
>> >>             int ini = Environment.TickCount;
>> >>
>> >>             string k = string.Empty;
>> >>
>> >>             for( int i = 0; i < 6000000; ++i )
>> >>             {
>> >>                 k = i.ToString();
>> >>             }
>> >>
>> >>             Console.WriteLine("val is {0} and time {1}", k,
>> >> Environment.TickCount - ini);
>> >>         }
>> >>     }
>> >> }
>> >>
>> >>
>> >> And the following results:
>> >>
>> >> >compareCompare.exe
>> >> val is 5999999 and time 3525
>> >>
>> >> >"c:\Archivos de programa\Mono-1.2.5.2\bin\mono.exe" 
>> >> >compareCompare.exe
>> >> val is 5999999 and time 11577
>> >>
>> >>
>> >> Thanks,
>> >>
>> >>
>> >> pablo
>> >>
>> >> _______________________________________________
>> >> 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