[Mono-list] Time problems on Mono

Miguel de Icaza miguel@ximian.com
Sat, 11 Dec 2004 13:15:59 -0500


Hello,

> My test was simple:
> // project created on 8/16/2004 at 4:00 PM
> using System;
> 
> class MainClass
> {
> 	public static void Main(string[] args)
> 	{
> 	   double sum=0;
>   		for ( int m=0;m<9;m++){
>   			for ( int n=0; n<=(1000* 1000 * 1000) ;n+=1 )
>   	  		{
> 				sum *= 1.0;
> 			}
> 		}
>   	}
> }
> 
> 
> The results was
> Under .net 6 secs. Under mono 9 secs, adding --optimize=all did not make a big difference.
> The same program in c++ compiled by g++ -O3 is also about 6 secs.

I ran this on GCC and GCC notices that multiplication by zero is a
no-op, so the actual multiplication never takes place, all you end up
with is a loop.

It seems simple to add such optimization to Mono, but I doubt it is of
any use in real applications, anyone multiplying by 1.0 probably has
worse problems in his code than Mono's optimizer.

If you change the 1.0 above by some other constant, say 4.5, you will
end up in the multi-minute world, just like Mono ends up.

Miguel.