Taking out all of the obvious caveats related to benchmarks and benchmark comparison, is there any study (an array of well documented and unbiased tests) that compares the average execution speed of the two mentioned languages? Thanks
-
You might want to look up this: http://shootout.alioth.debian.org/ . But note that they test C# with Mono and not with Microsoft.NET. – Rasmus Faber Jun 26 '09 at 13:25
-
These benchmarks tend to assume you have a well understand problem with unlimited high skilled developers time. For realistic projects, with evoling requirements, and a small number of developers with mixed abilities, the picture is much more complex and pure micro-benchmark speed becomes less important. – Peter Lawrey Apr 18 '10 at 07:17
-
If you are looking only for startup performance, this is a good benchmark: http://www.codeproject.com/KB/dotnet/RuntimePerformance.aspx – dmihailescu Aug 22 '10 at 22:23
5 Answers
The best comparison that I am aware of is The Computer Language Benchmarks Game.
It compares speed, memory use and source code size for (currently) 10 benchmarks across a large number of programming languages. The implementations of the benchmarks are user-submitted and there are continuous improvements, so the standings shift around somewhat.
The comparison is currently openjdk vs C# .NET Core.
Currently it is close, but .NET Core is slightly faster on most benchmarks.

- 48,631
- 24
- 141
- 189
-
54I don't think that comparing Java to Mono makes much sense, MS' .net runtime is probably a lot faster than Mono. – Erich Kitzmueller Jun 29 '09 at 07:32
-
3@ammoQ: That would have been my guess, too. But I looked it up and the following article seems to indicate that the performance is comparable: http://geekswithblogs.net/CISCBrain/articles/Mono_vs_dotNet_Performance_Test.aspx . – Rasmus Faber Jun 29 '09 at 08:12
-
4@ammoQ, Any particular reason to believe that .NET is faster than Mono per default? – Thorbjørn Ravn Andersen Apr 17 '10 at 15:09
-
@Thorbjørn: No, just a feeling in the gut and some experiences so out-dated I won't bother telling. Some discussion about it (including contributions from Jon Skeet): http://www.eggheadcafe.com/software/aspnet/32289725/benchmarks-java-vs-net.aspx – Erich Kitzmueller Apr 18 '10 at 11:10
-
Your assumption is correct. I remember seeing this a while back. Look around for benchmarks on the Vala language (essentially c# thats gets translated to standard c), it had a benchmark of mono vs .net – jdc0589 Aug 22 '10 at 22:25
-
@Rasmus Good find! The article itself is from 2005 but people keep running benchmarks and post results back in comments. – Andrei Андрей Листочкин Aug 22 '10 at 22:44
-
[Vista csc :: Java](http://shootout.alioth.debian.org/demo/benchmark.php?test=all&lang=csc&lang2=java) – igouy Apr 20 '11 at 20:46
-
@igouy: Very interesting. Also interesting is this: [Vista csc :: Mono](http://shootout.alioth.debian.org/demo/benchmark.php?test=all&lang=csc&lang2=csharp). It seems to disprove my assertion that Mono and .NET are comparable in speed. – Rasmus Faber Jan 02 '12 at 08:47
-
Since both of them are based on vm. it's improtant about choosing the vm. Both choose the offical vm is a good choice. – madper Feb 14 '13 at 10:34
-
In typical moderns apps using Generics C# is considerably faster than Java even on Android: http://blog.xamarin.com/android-in-c-sharp/#performance – markmnl Nov 20 '13 at 08:23
-
-
I am not sure about regular applications, but I have seen web app benchmarks for Mono vs .NET and .NET was 2-5x faster. – Sep 03 '14 at 13:54
Here's a nice recent study on the subject:
Numeric performance in C, C# and Java
Peter Sestoft (sestoft@itu.dk)
IT University of Copenhagen Denmark
Version 0.9.1 of 2010-02-19
Abstract:We compare the numeric performance of C, C# and Java on three small cases.
...

- 1
- 1

- 36,600
- 15
- 168
- 198
-
7The conclusion from the paper: "The experiments show that there is no obvious relation between the execution speeds of different soft- ware platforms, even for the very simple programs studied here: the C, C# and Java platforms are variously fastest and slowest." – Thorbjørn Ravn Andersen Apr 17 '10 at 15:11
-
7They executed the test programs on Mac OS X. For C# they used mono and used a virtual machine to test the performance of the .net runtime. In my opinion the C# benchmark values are flawed. – user23127 Jan 13 '13 at 10:30
-
1
-
2"Numeric performance" means using primitive types without any objects, virtual functions, etc. It misses 80% of the language. – Aleksandr Dubinsky Nov 29 '15 at 14:21
Both languages are evolving in terms of performance. At least in 2013, Microsoft's own Joe Duffy blogged:
Java is closer [to C++ in performance] than C# thanks to the excellent work in HotSpot-like VMs which employ code pitching and stack allocation.

- 22,436
- 15
- 82
- 99
This could invite a flamewar, but hey, it's my opinion...
First of all, if your site runs too slow, you'll need better hardware. Or more hardware and add load balancing to your site. If you're Google, you'll end up with huge server farms with thousands of machines that will seem to provide a lightning-fast performance, even if the sites themselves are developed in some outdated language.
Most languages have been optimized to get the best from their hardware and will outperform any other language in this specific environment with a specific setup. Comparing languages won't make much sense because there are thousands of techniques to optimize them even more. Besides, how do you measure performance to begin with?
Let's say that you look at execution speed. Language X might perform some task 2 times faster than language Y. However, language Y is more optimized for running multiple threads and could serve 10 times more users than language X in the same amount of time. Combine this and Y would be much faster in a client/server environment.
But then install X on an optimized system with an operating system that X likes a lot, with additional hardware, a gadzillion bytes of memory and disk space and a dozen or so CPU's and X will beat Y again.
So, what's the value of knowing the execution speed of languages? Or even the comparison of languages? How do we know that the ones who created the report weren't biased? How are we sure that they used the most optimal settings for every language? Did they even write the most optimal code to be tested? And how do you compare the end results anyways? Execution time per user? Or total execution time?
Back to languages X and Y. X runs a task in 2 seconds but it supports only 10 threads at the same time, thus 10 users. Y needs 6 seconds but serves up to 50 threads at the same time. X would be faster per user. In two seconds, X has processed 10 users. In 6 seconds, X has processed 30 users. But Y would have processed 50 users by that time. Thus Y would outperform X when you have lots of users, while X would out-perform Y with a low amount of users. (Or threads.) It would be interesting to see reports mentioning this, right?

- 25,901
- 20
- 83
- 149
-
8
-
Basically, I'm saying that you just can't compare two different languages, even if they're very similar, like C# and Java are. Thus a comparison of languages is useless, unless you're comparing for a very specific area. – Wim ten Brink Apr 18 '10 at 09:46
-
2
2021
Overview
For years, the applications created either with Java or on .NET/C# had a similar level of performance. However, Microsoft and many third-party contributors have made some significant investments in the optimization of this aspect and continue to improve. For example, the ASP.NET Core web framework allows you to serve 7 million requests per second on a single server. And according to TechEmpower tests, ASP.NET Core is way ahead of any Java web framework.
Research
https://github.com/ixy-languages/ixy-languages
Here's another good demonstration of the performance that can be achieved on the .NET platform — an example of a super-fast network driver written in different languages. The driver written in C# shows almost the same level of performance as C and Rust, slightly better than the Go language, and way ahead of all other high-level languages, including Java.

- 2,431
- 3
- 35
- 77