The Computer Language
24.11 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 #5 2.27 29,584 1485 8.79
C# .NET #2 30.38 28,804 584 30.37
* C# .NET #9 8.40 29,608 1232 33.33
C# .NET #6 9.93 29,272 1075 39.49
Java #3 39.96 44,308 1264 40.06
Java 10.85 44,612 1289 42.80
C# .NET #3 11.01 29,020 1117 43.46
C# .NET #8 43.80 28,760 519 43.78
Java #2 45.77 42,552 520 45.83
Java #8 45.90 42,568 517 45.97
n-body
source secs mem gz cpu secs
* C# .NET #9 3.17 28,604 2480 3.17
* C# .NET #4 3.75 28,504 2137 3.75
* C# .NET #7 4.80 28,564 1715 4.80
* C# .NET #6 4.83 28,512 1754 4.83
C# .NET #3 6.65 29,280 1311 6.64
C# .NET #2 6.89 29,284 1339 6.89
Java #4 6.88 42,028 1495 6.91
C# .NET #8 7.21 29,068 1335 7.21
Java #5 7.30 43,424 1435 7.36
Java #2 7.48 42,260 1430 7.52
Java #3 7.49 42,292 1436 7.52
Java #8 7.59 42,924 1322 7.64
C# .NET #0 7.66 29,360 1342 7.66
C# .NET 7.66 29,380 1424 7.66
Java 7.84 42,652 1437 7.88
spectral-norm
source secs mem gz cpu secs
* C# .NET #5 0.94 33,752 776 3.42
C# .NET #8 5.41 29,720 441 5.40
Java #8 5.43 43,368 453 5.49
C# .NET #2 1.52 29,864 1084 5.78
C# .NET #3 1.54 31,460 890 5.80
Java #3 1.57 44,160 762 5.93
Java #2 1.61 43,028 956 6.08
mandelbrot
source secs mem gz cpu secs
* C# .NET #7 3.21 66,484 915 12.50
* C# .NET 3.93 64,440 1980 15.41
* C# .NET #9 3.93 64,332 822 15.45
C# .NET #5 4.06 63,344 851 15.87
Java #2 4.08 82,216 802 16.06
Java #4 4.41 105,000 667 16.14
Java #6 4.19 82,232 808 16.42
Java 24.50 42,272 671 24.57
C# .NET #8 26.41 29,820 492 26.41
C# .NET #3 6.79 61,964 722 26.79
Java #3 6.96 82,972 910 27.54
Java #8 27.67 45,844 441 27.79
C# .NET #2 46.19 29,604 504 46.19
fasta
source secs mem gz cpu secs
C# .NET #9 1.21 29,432 1512 1.21
Java #4 3.28 44,352 1528 3.40
Java #6 1.16 49,848 2549 3.71
Java #5 1.24 49,640 2478 4.13
Java #2 4.45 48,896 1259 4.60
C# .NET #8 5.40 32,864 904 5.42
C# .NET #5 1.48 50,620 1702 5.45
C# .NET 1.70 36,636 2113 6.23
Java #8 10.12 182,140 894 10.66
k-nucleotide
source secs mem gz cpu secs
C# .NET 3.18 181,724 2046 10.77
C# .NET #6 5.63 180,500 1615 14.88
Java 4.92 427,448 1821 15.77
Java #6 7.27 426,032 1614 25.17
Java #3 7.34 426,540 1642 25.47
Java #4 34.33 197,748 1887 34.67
C# .NET #4 12.06 612,408 1725 42.10
C# .NET #7 42.74 613,184 1449 43.35
Java #5 22.10 222,396 2225 48.14
C# .NET #8 75.50 1,371,044 736 76.56
Java #8 78.46 2,083,000 786 80.86
reverse-complement
source secs mem gz cpu secs
C# .NET #9 0.59 733,932 2641 1.37
C# .NET 3.14 583,252 1130 3.18
C# .NET #6 1.55 1,027,196 1627 3.76
Java #6 3.15 2,032,996 760 3.79
C# .NET #5 2.53 1,025,008 1620 3.83
C# .NET #7 1.54 927,984 1312 4.25
Java #5 4.72 1,097,732 1115 4.84
Java #4 5.65 1,891,656 656 5.77
Java #7 23.98 1,037,708 1654 6.26
C# .NET #3 8.47 1,380,908 934 13.21
Java #3   Bad Output  
binary-trees
source secs mem gz cpu secs
Java #4 4.41 1,821,244 846 5.14
Java #6 4.87 1,782,568 535 5.63
Java #3 4.85 1,769,500 546 5.65
Java #2 5.09 1,820,068 558 5.83
Java #8 6.57 1,767,108 596 7.29
Java #7 2.62 1,803,192 841 8.14
C# .NET #8 13.50 883,524 601 15.31
C# .NET #7 5.34 1,074,228 706 17.42
C# .NET #2 5.37 1,083,480 717 17.60
C# .NET 6.11 3,178,448 668 19.93
C# .NET #3 6.45 2,900,008 688 20.33
C# .NET #6   Make Error  
pidigits
source secs mem gz cpu secs
* C# .NET #6 0.82 30,744 1182 0.82
* Java #3 0.80 41,900 770 0.83
* C# .NET #5 0.84 33,264 990 0.88
* C# .NET #4 1.29 31,392 1135 1.29
* Java #2 1.29 45,768 944 1.37
C# .NET #7 7.15 38,160 579 7.25
Java 7.68 482,056 807 8.75
regex-redux
source secs mem gz cpu secs
C# .NET #2 1.36 402,516 1881 2.60
Java #2 1.55 372,764 2201 3.16
C# .NET 4.60 599,212 641 4.83
C# .NET #5 1.74 614,536 679 5.02
Java 8.47 575,552 875 16.69
Java #6 5.60 1,237,440 746 17.12
Java #3 5.25 611,476 935 17.25
C# .NET #4 8.65 854,996 854 29.97
C# .NET

.NET SDK 9.0.100
Host Version: 9.0.0
Commit: 9d5a6a9aa4

<OutputType>Exe
<TargetFramework>net9.0
<ImplicitUsings>enable
<Nullable>enable
<AllowUnsafeBlocks>true
<ServerGarbageCollection>true
<ConcurrentGarbageCollection>true
<PublishAot>false

Java

java 23 2024-09-17
Java HotSpot(TM) 64-Bit Server VM
(build 23+37-2369,
mixed mode, sharing)