[Mono-dev] [Patch] to significantly shorten Char.cs

Andreas Nahr ClassDevelopment at A-SoftTech.com
Thu Jun 26 18:24:51 EDT 2008


Well the main improvement is the shortening of the String-Parameter methods.
It does not affect performance negatively as far as I measured because the
methods now get inlined but were too large before.
I know that the code wasn't duplicated for performance reasons before,
because I actually wrote that code. Well most of Char anyways... ;)

IsWhiteSpace is now somewhat faster. Similar Prog from below (do not have
the original anymore) went from 21 sec total to 16,5 sec (AMD 3,2Ghz XP)
(testing one positive + one negative case). It simply saves some opcodes.

public static void Main()
{
    int tickCount = Environment.TickCount;
    for (int i = 0; i < 0x3b9aca00; i++)
    {
        char.IsWhiteSpace('v');
    }
    Console.WriteLine((int) (Environment.TickCount - tickCount));
    tickCount = Environment.TickCount;
    for (int j = 0; j < 0x3b9aca00; j++)
    {
        char.IsWhiteSpace(' ');
    }
    Console.WriteLine((int) (Environment.TickCount - tickCount));
}

And no, IsWhiteSpace did not get optimized away ;)

> -----Ursprüngliche Nachricht-----
> Von: mono-devel-list-bounces at lists.ximian.com [mailto:mono-devel-list-
> bounces at lists.ximian.com] Im Auftrag von Atsushi Eno
> Gesendet: Donnerstag, 26. Juni 2008 23:25
> An: 'mono-devel'
> Betreff: Re: [Mono-dev] [Patch] to significantly shorten Char.cs
> 
> I have some comments even without reading your application/octet-stream
> patch (I ususally don't read them).
> 
> - Sometimes we have some code pieces that look like duplicates
>    exactly because of performance improvements.
> - For performance improvements there should be some benchmark
>    results with sources.
> 
> Atsushi Eno
> 
> 
> Andreas Nahr wrote:
> > The attached patch reduces code duplication in Char by more than 130
> lines
> > and improves the performance of some methods a little bit.
> >
> > Somebody please have a short look...
> >
> > Happy Hacking
> > Andreas
> >
> >
> > ---------------------------------------------------------------------
> ---
> >
> > _______________________________________________
> > Mono-devel-list mailing list
> > Mono-devel-list at lists.ximian.com
> > http://lists.ximian.com/mailman/listinfo/mono-devel-list
> 
> _______________________________________________
> 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