The Computer Language
24.09 Benchmarks Game

C# .NET versus Java fastest performance

How the programs are written matters! Always look at the source code.

If the fastest programs are hand-written vector instructions, does the host language matter? You might be more interested in the less optimised programs — more seconds, less gz source code.

fannkuch-redux
source secs mem gz cpu secs
C# .NET #8 2.22 31,568 1485 8.64
C# .NET #2 29.59 30,836 584 29.58
C# .NET #6 8.67 30,968 1075 34.39
C# .NET #9 9.08 32,348 1232 36.00
Java 10.04 42,708 1289 39.47
Java #3 40.81 42,920 1264 40.91
Java #2 44.33 41,012 520 44.38
C# .NET #3 11.34 31,120 1117 44.67
C# .NET #7   Bad Output  
n-body
source secs mem gz cpu secs
C# .NET #9 3.16 30,388 2480 3.16
C# .NET #4 3.75 30,516 2137 3.74
C# .NET #7 4.79 30,640 1715 4.79
C# .NET #6 4.82 30,640 1754 4.81
C# .NET #3 6.65 31,492 1311 6.64
C# .NET #2 6.83 31,524 1350 6.82
C# .NET #8 6.83 31,528 1339 6.82
Java #5 6.79 41,476 1435 6.83
Java #4 6.91 41,364 1495 6.95
Java #2 7.58 41,440 1430 7.62
Java #3 7.63 41,352 1436 7.67
C# .NET 7.80 31,508 1424 7.79
Java 7.89 41,616 1437 7.93
spectral-norm
source secs mem gz cpu secs
C# .NET #5 0.93 36,476 776 3.41
C# .NET 5.40 31,616 480 5.39
C# .NET #2 1.52 31,884 1084 5.76
C# .NET #3 1.54 33,792 890 5.86
Java #3 1.69 43,028 762 6.41
Java 7.08 42,384 521 7.14
Java #2 2.44 42,180 956 9.47
mandelbrot
source secs mem gz cpu secs
C# .NET #7 3.20 63,560 915 12.46
C# .NET #9 3.25 66,864 822 12.60
C# .NET 3.23 66,980 1980 12.62
C# .NET #5 4.04 66,356 851 15.80
Java #2 4.14 81,668 802 16.25
Java #4 4.44 104,696 667 16.25
Java #6 4.31 81,888 808 16.97
Java 25.75 41,428 671 25.81
C# .NET #3 6.82 64,780 722 26.83
Java #3 7.42 81,216 910 29.33
C# .NET #2 45.64 31,992 504 45.64
pidigits
source secs mem gz cpu secs
C# .NET #6 0.96 33,240 1182 0.95
C# .NET #5 0.93 35,096 990 0.96
Java #3 0.94 40,944 770 0.96
C# .NET #4 1.36 33,952 1135 1.35
Java #2 1.35 44,528 944 1.42
C# .NET #7 6.59 53,412 579 7.20
Java 7.63 491,600 807 8.66
regex-redux
source secs mem gz cpu secs
C# .NET #8 1.43 389,120 1881 2.67
Java #8 1.62 372,312 2201 3.20
C# .NET 4.60 847,380 641 4.84
C# .NET #5 2.11 860,544 679 6.32
Java 8.58 586,528 875 16.95
Java #6 5.59 1,235,356 746 17.14
Java #3 5.25 629,428 935 17.37
C# .NET #4 13.15 960,820 854 44.64
fasta
source secs mem gz cpu secs
C# .NET #9 1.21 26,424 1512 1.21
Java #4 3.16 42,812 1528 3.27
Java #6 1.18 48,364 2549 3.74
Java #5 1.26 48,824 2478 4.17
Java #2 4.39 47,624 1259 4.56
C# .NET #5 1.50 62,072 1702 5.46
C# .NET 1.84 52,300 2113 6.73
k-nucleotide
source secs mem gz cpu secs
C# .NET 3.04 184,820 2046 10.53
C# .NET #6 5.06 187,908 1615 12.77
Java 5.02 369,032 1821 16.31
Java #3 7.26 365,384 1642 25.09
Java #6 7.26 365,680 1614 25.28
Java #4 34.70 195,564 1887 35.08
C# .NET #7 40.69 762,328 1449 41.14
C# .NET #4 11.67 778,008 1725 41.58
Java #5 20.44 218,932 2225 44.56
reverse-complement
source secs mem gz cpu secs
C# .NET #8 0.56 736,084 2641 1.35
C# .NET 2.97 798,004 1130 3.15
C# .NET #5 2.64 1,026,620 1620 3.67
C# .NET #6 1.64 1,027,256 1627 3.95
Java #6 3.40 2,031,576 760 4.06
C# .NET #7 1.56 941,012 1312 4.23
Java #5 4.78 1,096,264 1115 4.92
Java #4 5.59 1,890,020 656 5.71
Java #7 23.61 1,036,152 1654 6.24
C# .NET #3 7.31 1,571,904 934 11.48
Java #3   Bad Output  
Java #8   Bad Output  
binary-trees
source secs mem gz cpu secs
Java #4 4.46 1,957,564 846 5.19
Java #3 4.90 2,032,184 546 5.67
Java #6 5.02 2,065,280 535 5.79
Java #2 5.11 2,064,188 558 5.83
Java #7 2.59 1,718,620 841 8.08
C# .NET #7 4.61 1,552,024 706 15.20
C# .NET #2 4.73 1,619,108 717 15.24
C# .NET #3 5.08 1,955,472 688 16.49
C# .NET 5.23 2,107,524 668 16.88
C# .NET #8   Make Error  
C# .NET

.NET SDK 8.0.301
Host Version: 8.0.6
Commit: 3b8b000a0e

<OutputType>Exe
<TargetFramework>net8.0
<ImplicitUsings>enable
<Nullable>enable
<AllowUnsafeBlocks>true
<ServerGarbageCollection>true
<ConcurrentGarbageCollection>true
<PublishAot>false
<OptimizationPreference>Speed
<IlcInstructionSet>native

Java

java 22 2024-03-19
Java HotSpot(TM) 64-Bit Server VM
(build 22+36-2370,
mixed mode, sharing)