[Mono-devel-list] Patch for String.Equals

Ben Maurer bmaurer at users.sourceforge.net
Sun Apr 4 19:48:52 EDT 2004


Hello,

This is very interesting. Am going to look into the assembly we generate
to see if this is the best we can do.

I am a bit unsure about the long compares, what do they gain us?
Internally, they are just two int compares.

In the mean time, something to ponder --
The fastest way to do this might be to generate some hand done assembly.
This way, we can take advantage of what the processor gives us.

A hint:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/sysdeps/i386/memcmp.S?rev=1.11&cvsroot=glibc

-- Ben

On Sun, 2004-04-04 at 19:04, Andreas Nahr wrote:
> Hi,
>  
> I've been looking into optimizing the speed of some core classes.
> The optimizations are mostly done using microbenchmarks, so somebody
> should test that for a bigger app like mcs (cant test because I devel
> on Windows without cygwin).
> Here is the first one:
> Using csc to compile and mcs to execute this speeds up String.Equals.
> Speed for 1 char it is about equal to old. For 2-7 chars it is about
> twice as fast (it has special handling for up to 7 chars). For 9 gain
> is about 20% and then grows with size for long needed comparisons (75
> chars it is about twice as fast as current solution).
> For small compares it is even a lot faster than MS impl. (I also think
> compares to strings that only differ in the 100th char should be
> rather seldom).
>  
> Andreas




More information about the Mono-devel-list mailing list