The Computer Language
Benchmarks Game

Java versus C# .NET fastest programs

Always look at the source code.

These are only the fastest programs. Do some of them use manually vectorized SIMD? Look at the other programs. They may seem more-like a fair comparison to you.

binary-trees
source secs mem gz busy cpu load
Java 2.48 1,725,776 835 7.86 74% 75% 97% 72%
C# .NET 4.81 1,881,564 676 15.47 81% 74% 83% 83%
fasta
source secs mem gz busy cpu load
Java 1.19 44,740 2543 3.50 75% 63% 87% 70%
C# .NET 1.21 152,684 1691 4.58 96% 97% 92% 93%
pidigits
source secs mem gz busy cpu load
Java 0.93 36,088 764 0.97 4% 0% 1% 99%
C# .NET 0.92 35,404 977 0.96 98% 3% 2% 1%
reverse-complement
source secs mem gz busy cpu load
Java 1.53 687,864 2183 3.50 80% 46% 57% 46%
C# .NET 1.50 950,648 1310 4.29 93% 63% 93% 38%
fannkuch-redux
source secs mem gz busy cpu load
Java 10.38 35,388 1282 40.84 99% 99% 98% 97%
C# .NET 8.40 30,848 1225 33.29 99% 100% 99% 99%
mandelbrot
source secs mem gz busy cpu load
Java 4.12 70,952 796 16.22 98% 98% 98% 99%
C# .NET 3.14 64,940 1974 12.30 99% 98% 97% 97%
k-nucleotide
source secs mem gz busy cpu load
Java 4.85 354,288 1812 15.92 80% 85% 87% 76%
C# .NET 3.29 182,860 2044 11.20 99% 86% 66% 90%
n-body
source secs mem gz busy cpu load
Java 6.77 35,432 1489 6.82 100% 1% 0% 0%
C# .NET 3.84 32,788 2125 4.09 1% 4% 99% 2%
spectral-norm
source secs mem gz busy cpu load
Java 1.58 39,408 756 5.97 94% 94% 96% 94%
C# .NET 0.82 35,048 764 2.99 89% 96% 89% 89%
regex-redux
source secs mem gz busy cpu load
Java 5.31 793,572 929 17.50 79% 78% 83% 89%
C# .NET 1.42 280,892 1869 2.69 30% 39% 86% 35%
Java

openjdk 17 2021-09-14
OpenJDK Runtime Environment (build 17+35-2724)
OpenJDK 64-Bit Server VM (build 17+35-2724, mixed mode, sharing)

C# .NET

.NET SDK 5.0.201
Host Version: 5.0.4; Commit: f27d337295
<ServerGarbageCollection>true</ServerGarbageCollection>