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

William Garrison monodevlist at mobydisk.com
Sat Jun 5 11:24:24 EDT 2004


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.

I know that I could optimize the code to do fewer string compares and to 
use hashes.  Currently I do O(N^2) compares to perform the diff.  But 
since the performance difference between Mono and .NET is so huge, I 
think time would be better spent in notifying the developers of the 
disparity and seeing what can be done to fix it.

After all that, I want to know:
1) What is the current status of string performance under Mono?
2) What can I give someone to help demonstrate or track down the problem?

Below is the relevant portion of the profiling output.

Total time spent compiling 787 methods (sec): 0.22
Slowest method to compile (sec): 0.01: System.IntPtr::.ctor(int)
Time(ms) Count   P/call(ms) Method name
########################
  31486.000       1  31486.000 
System.Object::runtime_invoke_void_string[](object,intptr,intptr,intptr)
   Callers (with count) that contribute at least for 1%:
########################
  31486.000       1  31486.000 
MobyDisk.CodeReview.CodeReview::Main(string[])
   Callers (with count) that contribute at least for 1%:
            1  100 % 
System.Object::runtime_invoke_void_string[](object,intptr,intptr,intptr)
########################
  31476.000       1  31476.000 
MobyDisk.CodeReview.CodeReview::DoStuff(string[])
   Callers (with count) that contribute at least for 1%:
            1  100 % MobyDisk.CodeReview.CodeReview::Main(string[])
########################
  24485.000       1  24485.000 
MobyDisk.CodeReview.Difference::ApplyDifference()
   Callers (with count) that contribute at least for 1%:
            1  100 % MobyDisk.CodeReview.CodeReview::DoStuff(string[])
########################
  20899.000 2117344    0.010 
MobyDisk.CodeReview.Difference::stringMatch(string,string)
   Callers (with count) that contribute at least for 1%:
      2117344  100 % MobyDisk.CodeReview.Difference::ApplyDifference()
########################
  20108.000 2117382    0.009   System.String::Compare(string,string,bool)
   Callers (with count) that contribute at least for 1%:
      2117344  99 % 
MobyDisk.CodeReview.Difference::stringMatch(string,string)




More information about the Mono-devel-list mailing list