The Computer Language
24.12 Benchmarks Game

more-similar less-idiosyncratic


When programs are idiomatic someone will say they are not comparable.

Are they similar-enough to be comparable for your purposes? Will someone then say the programs are not idiomatic.

If only more-idiomatic was not less-comparable!


Here are a few naive un-optimised single-thread #8 programs transliterated lowest-common-denominator style into different programming languages from the same original.


Also let's repeat the calculations a dozen times in-process to amortize startup and JIT warmup costs even more —

elapsed secs / fastest  
  12× in-process  
× source ×    
1.0 Intel C 1.0 Intel C spectral-norm
1.0 Swift 1.0 Swift fannkuch-redux
1.0 C gcc 1.0 C gcc n-body
1.0 C clang 1.0 C clang n-body
1.0 C clang 1.0 C clang fannkuch-redux
1.1 Intel C 1.1 Intel C n-body
1.1 C gcc 1.1 C gcc fannkuch-redux
1.2 Swift 1.3 Swift n-body
1.2 Intel C 1.2 Intel C fannkuch-redux
1.3 C# aot 1.3 C# aot n-body
1.3 C# aot 1.3 C# aot fannkuch-redux
1.3 Java 1.6 Java fannkuch-redux
1.3 Go 1.3 Go fannkuch-redux
1.4 Dart 1.3 Dart n-body
1.4 Java 1.4 Java n-body
1.7 Node.js 1.9 Node.js fannkuch-redux
1.7 Node.js 1.8 Node.js n-body
1.7 Go 1.7 Go n-body
2.0 C# aot 2.0 C# aot spectral-norm
2.0 Swift 2.0 Swift spectral-norm
2.0 Go 2.0 Go spectral-norm
2.0 Dart 2.0 Dart fannkuch-redux
2.0 C gcc 2.0 C gcc spectral-norm
2.0 C clang 2.0 C clang spectral-norm
2.0 Java 2.1 Java spectral-norm
2.4 Node.js 2.4 Node.js spectral-norm
4.1 Dart 4.1 Dart spectral-norm
20 Java -Xint     fannkuch-redux
29 Java -Xint 29 Java -Xint n-body
30 Java -Xint 31 Java -Xint spectral-norm
44 PHP 44 PHP n-body
49 PHP     fannkuch-redux
51 PHP 51 PHP spectral-norm
55 Ruby yjit     fannkuch-redux
57 Ruby yjit 58 Ruby yjit n-body
63 Ruby yjit 66 Ruby yjit spectral-norm
64 Python 3     fannkuch-redux
94 Python 3     n-body
142 Python 3     spectral-norm
586 Matz's Ruby     n-body
626 Matz's Ruby     spectral-norm

Seemingly similar programs behave differently when the language implementations behave differently. Do they have the same default stdio buffering? Do the programs need to be written differently and run differently to make them behave the same.


To be less similar so they are more comparable!

elapsed secs / fastest significant io
 
× source  
1.0 Intel C mandelbrot
1.0 C# aot fasta
1.0 Go k-nucleotide
1.0 C gcc mandelbrot
1.1 C clang mandelbrot
1.1 C# aot mandelbrot
1.1 Swift mandelbrot
1.1 Go mandelbrot
1.2 Java mandelbrot
1.2 C# aot k-nucleotide
1.2 Intel C fasta
1.3 PHP k-nucleotide
1.3 C clang fasta
1.3 C gcc fasta
1.3 Java k-nucleotide
1.6 Java fasta
1.8 Go fasta
2.3 Node.js k-nucleotide
2.9 Swift k-nucleotide
3.0 Node.js fasta
3.0 Node.js mandelbrot
3.0 Swift fasta
3.9 Python 3 k-nucleotide
5.8 Dart fasta
7.9 PHP fasta
8.4 Dart mandelbrot
8.6 Ruby yjit k-nucleotide
9.0 Dart k-nucleotide
18 PHP mandelbrot
25 Python 3 fasta
26 Java -Xint mandelbrot
31 Ruby yjit fasta
39 Ruby yjit mandelbrot
53 Java -Xint fasta
64 Python 3 mandelbrot
126 Matz's Ruby fasta
Such comparisons raise a nest of issues all their own: for example, is it really the same program when written in the two compared languages? (Will Partain, 1992.)

 


Throw the ratios together and give them a shake!

elapsed secs / fastest Geometric Mean
1.1 Intel C  
1.3 C clang  
1.3 C gcc  
1.3 C# aot  
1.5 Java  
1.5 Go  
1.6 Swift  
2.2 Node.js  
3.4 Dart  
22 PHP  
30 Java -Xint  
41 Ruby yjit  
42 Python 3  
359 Matz's Ruby