I spent 10 minutes cooking up 2 naive implementations of finding primes 
between 1 and 10^7 in both C# [http://pastebin.com/RDGQZPAr] and Java [
http://pastebin.com/JpY8FsA1], and the result is that C# is faster:

Java: 664579 primes were found in 8262 ms
C#: 664579 primes were found in 7698.878 ms

...using default configurations for JDK7 (Server HotSpot) and Mono 2.10.5 
JIT on my 64bit Ubuntu workstation. It's pretty simple CPU work with method 
invocation within iteration, some increments/adds, a bitwise-operation, a 
library call, modulus and of course branching/comparisons.

Now notice what happens when I change the type from long to ulong (unsigned 
long) in C#:

C#: 664579 primes were found in 5651.8524 ms

It's my experience that C#'s extra features (in this case, unsigned types) 
just caters better to programming into the language, not in it* and more 
predictable performance. In other words, the JVM JIT might be superior to 
Mono's, but that's hardly the whole story!

* Steve McConnell, Code Complete.

-- 
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/javaposse/-/vRvJciCIQkYJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en.

Reply via email to