views:

109

answers:

2

I have a simple Application built using Mono on Ubuntu that prints out the entries of a list in sequence. The code takes about 6 ms to execute on Ubuntu, however the same code takes about 40 ms to execute on windows. Is there a reason why the same application code would run faster on Ubuntu than it would using the actual .net runtime on windows ?

+1  A: 

Mono is not a port of the .Net runtime. From the 'What is Mono?' page:

It is an open source implementation of Microsoft's .Net Framework based on the ECMA standards for C# and the Common Language Runtime.

It's entirely possible that the Mono implementation of some features could be faster than the .Net implementation.

Another possibility is that the code you're running is not as optimized as it could be. Perhaps see if there are bottlenecks or loops that could be modified?

cofiem
Thanks for the reply. I tried running the code using mono and not the .net framework on Windows too and it performed the same as the .net runtime did, both were much slower than mono's execution on Ubuntu. However even if my code isn't optimized, the deficiencies should carry over to both platforms. I haven't modified the code at all, I am running the same code on both platforms. Modifying the code to be more efficient wouldn't really solve anything if the same snippet is running on both environments. Essentially Ubuntu is executing "un-optimized code" faster than windows.
Cranialsurge
Interesting, could you narrow down on the code that's slower? Or post some code? If you have one of the full versions of Visual Studio, you could use it's profiling tools. http://msdn.microsoft.com/en-us/magazine/cc337887.aspx
cofiem
I will modify the code with some of the suggestions posted above and see if I can get a more relevant test.
Cranialsurge
+4  A: 

If you're printing to the console, then the speed difference would come from the fact that the Windows cmd.exe is awfully slow. Direct the output to a file and then measure the execution time.

skolima
This answer is inaccurate... Perhaps replace "awfully" with "insanely"? </tongue-in-cheek>
Arafangion
This may be true, although I would *hope* that the Windows cmd is not that slow.
cofiem