[Mono-devel-list] Mono strings 10x slower than .NET

Paolo Molaro lupus at ximian.com
Sun Jun 6 05:24:21 EDT 2004


On 06/05/04 William Garrison wrote:
> I just compiled my first application in Mono.  It's a code highlighter & 
> diff tool.  It runs great under Mono, except that it runs 10 times 
> slower than under .NET!  .NET runs my standard test case in 2-3 seconds, 
> while Mono takes 19-23 seconds.  The times are the same on both Windows 
> and Linux (RH9) and with the EXE file compiled under both .NET and Mono.
> 
> I used the --profile option, and the problem appears to be 
> System.String::Compare.  My code is unoptimized, and does LOTS of string 
> compares.  When profiling, the code took 32 seconds to run, with 24 
> seconds being the string compares.
[...]
> After all that, I want to know:
> 1) What is the current status of string performance under Mono?

When using culture-sensitive compares it's quite slow, especially if
mono was compiled with ICU support (collation and other issues add a lot
of overhead).
Do you really need the culture-sensitive Compare? CompareOrdinal
should be slightly faster, especially with mono build without ICU support.
Or, you may want to use String.Equals() which is tons faster and
probably what you need to do in a diff-like tool anyway.

> 2) What can I give someone to help demonstrate or track down the problem?

We know about the compare slowness (I think we discussed it at the
Boston meeting, too), but nobody had the time yet to through away the
current ICU/Compare code and rewrite it. See if using Equals() solves
the issue for you, in the meantime.

lupus

-- 
-----------------------------------------------------------------
lupus at debian.org                                     debian/rules
lupus at ximian.com                             Monkeys do it better



More information about the Mono-devel-list mailing list