Table of Content
Overview
The benchmarks follow the criteria:
-
They are written as the average software developer would write them, i.e.
- The algorithms are implemented as cited in public sources;
- The libraries are used as described in the tutorials, documentation and examples;
- The used data structures are idiomatic.
-
The used algorithms are similar between the languages (as the reference implementations), variants are acceptable if the reference implementation exists.
-
All final binaries are releases (optimized for performance if possible) as debug performance may vary too much depending on the compiler.
My other benchmarks: jit-benchmarks, crystal-benchmarks-game
Measurements
The measured values are:
- time spent for the benchmark execution (loading required data and code self-testing are not measured);
- memory consumption of the benchmark process, reported as
base
+increase
, wherebase
is the RSS before the benchmark andincrease
is the peak increase of the RSS during the benchmark; - energy consumption of the CPU package during the benchmark: PP0 (cores) + PP1 (uncores like GPU) + DRAM. Currently, only Intel CPU are supported via the powercap interface.
All values are presented as: median
±median absolute deviation
.
UPDATE: 2022-12-10
Test Cases
Brainfuck
Testing brainfuck implementations using two code samples (bench.b and mandel.b). Supports two mode:
- Verbose (default). Prints the output immediately.
- Quiet (if QUIET environment variable is set). Accumulates the output using Fletcher-16 checksum, and prints it out after the benchmark.
bench.b
Language | Time, s | Memory, MiB | Energy, J |
---|---|---|---|
Racket (Syntax Objects) | 1.297±0.000 | 110.95±00.38 + 0.00±00.00 | 47.09±00.05 |
C++/g++ | 1.300±0.001 | 1.84±00.02 + 0.00±00.00 | 51.96±00.05 |
Rust | 1.545±0.001 | 0.94±00.02 + 0.00±00.00 | 61.73±00.09 |
Java | 1.651±0.000 | 37.60±00.21 + 1.55±00.33 | 64.40±00.14 |
V/gcc | 1.654±0.000 | 1.84±00.01 + 0.00±00.00 | 64.02±00.14 |
D/ldc2 | 1.657±0.000 | 3.02±00.04 + 0.00±00.00 | 66.26±00.09 |
D/gdc | 1.661±0.000 | 6.59±00.02 + 0.00±00.00 | 68.09±00.48 |
C/gcc | 1.667±0.000 | 0.89±00.01 + 0.00±00.00 | 64.70±00.13 |
C/clang | 1.670±0.000 | 0.89±00.01 + 0.00±00.00 | 65.33±00.38 |
Kotlin/JVM | 1.683±0.009 | 41.55±00.07 + 0.43±00.09 | 65.59±00.30 |
C++/clang++ | 1.742±0.000 | 1.61±00.01 + 0.00±00.00 | 67.71±00.22 |
Zig | 1.835±0.000 | 0.91±00.02 + 0.00±00.00 | 71.17±00.13 |
Go | 1.905±0.000 | 3.11±00.04 + 0.00±00.00 | 73.82±00.15 |
OCaml | 1.912±0.001 | 2.87±00.02 + 1.98±00.00 | 85.40±00.82 |
Chez Scheme | 1.933±0.000 | 24.84±00.03 + 4.34±00.06 | 79.82±00.12 |
F#/.NET Core | 1.952±0.000 | 108.79±00.11 + 0.60±00.00 | 80.12±00.23 |
Nim/gcc | 1.962±0.001 | 2.00±00.03 + 0.00±00.00 | 77.19±00.80 |
C#/.NET Core | 1.979±0.000 | 104.35±00.10 + 0.21±00.00 | 81.29±00.08 |
Racket | 2.016±0.013 | 92.74±00.18 + 0.00±00.00 | 81.31±00.66 |
Vala/gcc | 2.090±0.001 | 4.34±00.03 + 0.00±00.00 | 78.35±00.12 |
Nim/clang | 2.111±0.000 | 2.29±00.01 + 0.00±00.00 | 81.86±00.13 |
Go/gccgo | 2.176±0.000 | 24.22±00.05 + 0.00±00.00 | 85.32±00.77 |
Vala/clang | 2.266±0.000 | 4.31±00.04 + 0.00±00.00 | 85.08±00.08 |
V/clang | 2.356±0.025 | 1.88±00.02 + 0.00±00.00 | 101.86±01.18 |
Crystal | 2.363±0.000 | 2.90±00.07 + 0.00±00.00 | 94.12±00.63 |
Julia | 2.581±0.006 | 207.32±00.06 + 0.65±00.02 | 99.89±00.47 |
MLton | 2.608±0.000 | 0.98±00.02 + 0.92±00.08 | 104.55±01.65 |
C#/Mono | 2.685±0.000 | 24.98±00.11 + 0.00±00.00 | 107.55±00.29 |
D/dmd | 3.218±0.001 | 3.52±00.03 + 0.00±00.00 | 123.14±01.32 |
Scala | 3.228±0.010 | 66.81±00.18 + 166.50±25.97 | 135.27±01.02 |
Haskell (MArray) | 3.851±0.000 | 4.90±01.05 + 5.80±01.02 | 154.33±00.11 |
Haskell (FP) | 3.889±0.003 | 5.92±00.05 + 4.93±00.00 | 165.24±00.42 |
Node.js | 4.150±0.002 | 42.88±00.04 + 0.31±00.00 | 165.97±00.46 |
Swift | 5.450±0.000 | 15.28±00.83 + 0.00±00.00 | 204.49±00.28 |
Ruby/truffleruby (--jvm) | 6.413±0.133 | 409.74±02.52 + 674.12±70.76 | 309.38±09.75 |
Lua/luajit | 6.491±0.016 | 2.43±00.01 + 0.00±00.00 | 259.21±00.50 |
Ruby/truffleruby | 7.043±0.033 | 303.07±00.24 + 359.89±06.85 | 332.99±01.45 |
Python/pypy | 12.191±0.015 | 60.78±00.15 + 30.13±00.02 | 510.36±02.22 |
Idris | 15.762±0.045 | 20.63±00.07 + 8.82±00.06 | 680.89±05.22 |
Ruby (--jit) | 40.816±0.150 | 270.58±00.01 + 0.25±00.01 | 1635.12±05.64 |
Elixir | 43.256±0.087 | 71.45±01.13 + 0.00±00.00 | 1928.27±14.75 |
Lua | 50.611±0.046 | 2.27±00.04 + 0.00±00.00 | 1955.56±02.08 |
Ruby | 87.260±1.288 | 13.96±00.04 + 0.00±00.00 | 3609.87±41.40 |
Ruby/jruby | 87.322±1.059 | 189.47±01.28 + 116.82±02.04 | 3849.08±46.49 |
Python | 195.534±1.465 | 10.41±00.04 + 0.00±00.00 | 7834.28±87.23 |
Tcl (FP) | 271.758±1.871 | 3.81±00.09 + 0.00±00.00 | 11395.20±79.30 |
Perl | 315.489±2.478 | 7.14±00.03 + 0.00±00.00 | 12703.58±98.49 |
Tcl (OOP) | 524.988±2.867 | 3.96±00.02 + 0.00±00.00 | 22223.01±139.78 |
mandel.b
Language | Time, s | Memory, MiB | Energy, J |
---|---|---|---|
C++/g++ | 10.145±0.016 | 1.83±00.02 + 2.39±00.04 | 410.27±02.84 |
C/gcc | 14.201±0.004 | 0.89±00.02 + 0.81±00.03 | 557.98±02.04 |
Racket (Syntax Objects) | 14.285±0.030 | 112.31±00.49 + 71.15±00.08 | 566.11±01.26 |
Kotlin/JVM | 14.315±0.027 | 41.63±00.10 + 1.19±00.17 | 586.70±01.57 |
D/ldc2 | 14.920±0.020 | 3.04±00.02 + 0.84±00.04 | 598.76±02.58 |
Zig | 15.007±0.008 | 0.91±00.01 + 1.41±00.00 | 592.52±02.01 |
C/clang | 15.128±0.013 | 0.89±00.02 + 0.87±00.09 | 647.86±05.03 |
Rust | 15.262±0.021 | 0.91±00.01 + 1.10±00.03 | 598.93±02.53 |
D/gdc | 15.371±0.073 | 6.57±00.02 + 1.36±00.02 | 644.91±02.18 |
C++/clang++ | 15.573±0.006 | 1.62±00.01 + 1.98±00.05 | 636.74±04.30 |
V/gcc | 15.903±0.340 | 1.85±00.04 + 1.19±00.01 | 632.63±15.82 |
Crystal | 15.924±0.168 | 2.91±00.03 + 0.60±00.02 | 663.38±11.25 |
C#/.NET Core | 16.346±0.019 | 104.49±00.05 + 0.88±00.00 | 682.67±04.50 |
Swift | 18.069±0.067 | 16.12±00.02 + 0.00±00.00 | 727.04±03.39 |
Vala/gcc | 18.476±0.004 | 4.22±00.04 + 1.45±00.02 | 691.94±00.47 |
Java | 18.659±0.023 | 37.73±00.23 + 2.05±00.31 | 744.47±01.69 |
Go | 19.488±0.018 | 3.07±00.04 + 1.28±00.00 | 730.68±00.89 |
Go/gccgo | 19.922±0.005 | 24.25±00.12 + 1.27±00.01 | 819.93±00.81 |
Vala/clang | 20.250±0.007 | 4.26±00.03 + 1.46±00.12 | 783.48±00.44 |
Scala | 20.975±0.012 | 67.25±00.16 + 141.43±00.12 | 881.11±01.30 |
Nim/gcc | 22.399±0.278 | 2.00±00.02 + 0.52±00.00 | 901.24±14.68 |
V/clang | 23.011±0.086 | 1.87±00.01 + 1.18±00.00 | 977.86±04.52 |
Nim/clang | 24.833±0.482 | 2.28±00.01 + 0.51±00.00 | 987.29±23.00 |
OCaml | 26.219±0.039 | 3.45±00.02 + 3.74±00.12 | 1247.55±10.90 |
Chez Scheme | 27.790±0.046 | 25.31±00.03 + 3.92±00.00 | 1215.67±02.96 |
Node.js | 28.194±0.527 | 42.91±00.05 + 6.17±00.19 | 1178.23±21.84 |
Julia | 29.584±0.036 | 207.95±00.09 + 0.49±00.01 | 1126.40±06.02 |
C#/Mono | 31.521±0.047 | 25.01±00.04 + 0.82±00.00 | 1337.07±04.01 |
F#/.NET Core | 34.950±0.035 | 108.86±00.10 + 2.22±00.06 | 1442.68±02.23 |
Lua/luajit | 35.086±0.039 | 2.44±00.03 + 0.44±00.00 | 1401.10±01.44 |
Racket | 36.847±0.435 | 93.33±00.71 + 0.25±00.08 | 1621.75±16.77 |
Haskell (MArray) | 37.327±0.011 | 5.72±00.02 + 6.11±00.00 | 1520.44±07.50 |
D/dmd | 37.414±0.004 | 3.50±00.05 + 0.97±00.03 | 1365.92±05.55 |
MLton | 44.858±0.031 | 1.61±00.09 + 4.11±00.00 | 1924.75±13.80 |
Python/pypy | 48.295±0.176 | 60.86±00.03 + 30.54±00.28 | 2043.82±21.99 |
Ruby/truffleruby (--jvm) | 66.508±0.063 | 408.76±03.32 + 611.12±29.67 | 2784.36±07.21 |
Idris | 67.460±0.094 | 21.96±00.06 + 9.56±00.02 | 2915.79±10.83 |
Haskell (FP) | 79.443±0.133 | 5.82±00.04 + 75.83±00.00 | 3315.86±27.08 |
Ruby/truffleruby | 81.328±0.292 | 302.54±01.09 + 263.13±20.03 | 3816.09±42.42 |
Base64
Testing base64 encoding/decoding of the large blob into the newly allocated buffers.
Language | Time, s | Memory, MiB | Energy, J |
---|---|---|---|
C/gcc (aklomp) | 0.099±0.000 | 2.07±00.02 + 0.00±00.00 | 4.64±00.06 |
C/clang (aklomp) | 0.099±0.001 | 2.07±00.04 + 0.00±00.00 | 4.59±00.07 |
PHP | 0.106±0.000 | 17.31±00.09 + 0.00±00.00 | 4.78±00.07 |
Rust | 0.970±0.000 | 2.08±00.02 + 0.21±00.03 | 39.37±00.21 |
C/clang | 0.997±0.000 | 2.00±00.07 + 0.00±00.00 | 36.74±00.21 |
C/gcc | 1.012±0.000 | 2.07±00.03 + 0.00±00.00 | 37.18±00.48 |
D/ldc2 | 1.037±0.001 | 3.40±00.27 + 3.61±00.19 | 43.16±00.52 |
Nim/gcc | 1.082±0.001 | 1.68±00.05 + 5.23±00.09 | 42.43±00.42 |
Nim/clang | 1.095±0.001 | 1.90±00.04 + 5.27±00.07 | 43.55±00.35 |
Crystal | 1.102±0.001 | 3.49±00.04 + 1.18±00.04 | 44.99±00.15 |
V/gcc | 1.349±0.000 | 2.39±00.03 + 2376.18±00.26 | 50.68±00.01 |
V/clang | 1.380±0.001 | 2.38±00.01 + 2376.79±00.86 | 52.53±00.10 |
Ruby (--jit) | 1.386±0.010 | 271.00±00.04 + 90.38±10.11 | 54.11±00.59 |
Ruby | 1.388±0.001 | 14.65±00.01 + 58.72±00.08 | 53.68±00.33 |
Java | 1.511±0.013 | 39.32±00.04 + 254.12±22.32 | 62.27±00.93 |
Scala | 1.606±0.055 | 64.90±00.28 + 330.26±14.92 | 68.84±01.17 |
Kotlin/JVM | 1.636±0.028 | 42.55±00.12 + 249.05±04.14 | 69.13±01.45 |
Vala/gcc | 1.643±0.001 | 5.54±00.05 + 0.13±00.02 | 62.89±00.31 |
Vala/clang | 1.644±0.000 | 5.50±00.05 + 0.15±00.02 | 63.06±00.69 |
C++/clang++ (libcrypto) | 1.711±0.002 | 5.09±00.05 + 0.71±00.03 | 68.44±00.89 |
C++/g++ (libcrypto) | 1.712±0.003 | 5.70±00.10 + 0.72±00.04 | 68.35±00.55 |
Node.js | 1.724±0.003 | 42.61±00.06 + 43.70±00.10 | 69.32±00.88 |
Go | 1.877±0.001 | 4.25±00.03 + 4.01±00.11 | 80.54±00.28 |
Perl (MIME::Base64) | 1.951±0.017 | 14.90±00.05 + 0.13±00.05 | 78.31±00.82 |
F#/.NET Core | 2.342±0.043 | 109.31±00.06 + 46.62±03.14 | 87.36±00.83 |
D/gdc | 2.436±0.004 | 7.55±00.04 + 3.35±00.00 | 106.92±00.60 |
C#/.NET Core | 2.647±0.058 | 104.54±00.13 + 47.83±06.26 | 96.55±02.21 |
Python | 2.711±0.002 | 10.28±00.05 + 0.60±00.01 | 105.56±00.92 |
Zig | 2.951±0.000 | 1.58±00.02 + 0.00±00.00 | 130.14±01.64 |
D/dmd | 3.026±0.001 | 4.15±00.04 + 3.35±00.00 | 129.20±01.47 |
Python/pypy | 3.582±0.002 | 60.86±00.01 + 31.50±00.15 | 157.11±01.03 |
Tcl | 3.632±0.004 | 5.10±00.02 + 0.00±00.00 | 146.59±01.31 |
Go/gccgo | 3.714±0.003 | 25.25±00.16 + 7.84±00.38 | 166.93±00.68 |
C#/Mono | 4.712±0.019 | 25.65±00.17 + 18.70±00.02 | 194.51±00.78 |
Julia | 5.051±0.005 | 226.05±00.04 + 42.61±00.43 | 189.58±03.14 |
Ruby/truffleruby (--jvm) | 5.136±0.010 | 407.71±02.03 + 211.28±15.72 | 240.17±02.78 |
Ruby/jruby | 10.708±0.121 | 186.69±00.85 + 79.64±00.52 | 421.28±03.40 |
Perl (MIME::Base64::Perl) | 13.619±0.141 | 16.21±00.08 + 0.23±00.05 | 572.56±03.68 |
Ruby/truffleruby | 15.536±0.010 | 302.86±00.68 + 263.68±04.10 | 649.08±08.68 |
Json
Testing parsing and simple calculating of values from a big JSON file.
Few notes:
- gason mutates input strings;
- simdjson requires input strings with batch of trailing zeros: a special zero padding for SIMD instructions;
- DAW JSON Link "NoCheck" skips some JSON structure correctness checks;
- DAW JSON Link, gason, default (not "Precise") RapidJSON, and D implementations except Mir-based have some inaccuracies in number parsing:
Language | Time, s | Memory, MiB | Energy, J |
---|---|---|---|
C++/clang++ (simdjson On-Demand) | 0.066±0.000 | 112.52±00.02 + 60.11±00.03 | 2.71±00.01 |
C++/g++ (simdjson On-Demand) | 0.066±0.000 | 113.29±00.32 + 60.11±00.29 | 2.72±00.02 |
C++/clang++ (DAW JSON Link NoCheck) | 0.070±0.001 | 112.38±00.06 + 0.00±00.00 | 2.95±00.03 |
C++/g++ (DAW JSON Link NoCheck) | 0.085±0.000 | 113.23±00.05 + 0.00±00.00 | 3.36±00.01 |
C++/clang++ (DAW JSON Link) | 0.086±0.001 | 112.41±00.06 + 0.00±00.00 | 3.61±00.05 |
C++/g++ (DAW JSON Link) | 0.101±0.000 | 113.23±00.03 + 0.00±00.00 | 4.14±00.02 |
Rust (Serde Typed) | 0.102±0.000 | 111.62±00.07 + 12.02±00.13 | 4.29±00.03 |
Rust (Serde Custom) | 0.108±0.000 | 111.35±00.03 + 0.00±00.00 | 4.45±00.02 |
C++/g++ (gason) | 0.133±0.000 | 113.15±00.09 + 96.96±00.04 | 5.26±00.01 |
C++/g++ (simdjson DOM) | 0.133±0.000 | 113.27±00.32 + 176.90±00.30 | 5.70±00.02 |
C++/clang++ (gason) | 0.144±0.000 | 112.35±00.06 + 96.97±00.00 | 5.82±00.01 |
C++/clang++ (simdjson DOM) | 0.144±0.000 | 112.47±00.04 + 177.15±00.00 | 6.15±00.02 |
D/ldc2 (Mir Asdf DOM) | 0.145±0.000 | 112.78±00.05 + 61.27±00.03 | 5.98±00.03 |
C++/g++ (RapidJSON) | 0.168±0.000 | 113.23±00.05 + 122.23±00.59 | 7.01±00.07 |
Scala (jsoniter-scala) | 0.175±0.001 | 288.19±00.12 + 25.08±00.53 | 9.59±00.05 |
C++/clang++ (RapidJSON) | 0.230±0.000 | 112.41±00.07 + 128.97±00.03 | 9.57±00.04 |
D/ldc2 (Mir Amazon's Ion DOM) | 0.236±0.000 | 112.89±00.02 + 80.70±00.00 | 9.85±00.07 |
Go (Sonic) | 0.237±0.002 | 119.77±00.09 + 111.84±00.06 | 10.21±00.10 |
C++/g++ (RapidJSON Precise) | 0.243±0.001 | 113.23±00.07 + 128.88±00.06 | 10.27±00.09 |
Go (goccy/go-json) | 0.271±0.000 | 115.83±00.09 + 112.15±00.19 | 10.63±00.02 |
C++/clang++ (RapidJSON Precise) | 0.313±0.000 | 112.41±00.01 + 129.00±00.00 | 13.43±00.08 |
C/clang (yajl) | 0.368±0.000 | 110.86±00.01 + 0.00±00.00 | 16.11±00.17 |
C/gcc (yajl) | 0.371±0.001 | 110.87±00.05 + 0.00±00.00 | 15.98±00.04 |
Zig | 0.387±0.001 | 110.92±00.02 + 12.18±00.00 | 19.13±00.06 |
Nim/clang (jsony) | 0.401±0.000 | 111.40±00.01 + 42.74±00.01 | 17.16±00.05 |
C++/g++ (Boost.JSON) | 0.401±0.000 | 113.30±00.05 + 435.95±00.07 | 16.68±00.06 |
C++/g++ (RapidJSON SAX) | 0.404±0.001 | 113.02±00.02 + 0.00±00.00 | 16.62±00.05 |
Nim/gcc (jsony) | 0.408±0.001 | 111.08±00.03 + 42.77±00.04 | 17.46±00.08 |
C++/clang++ (Boost.JSON) | 0.421±0.001 | 112.42±00.04 + 436.31±00.00 | 17.73±00.11 |
C++/g++ (RapidJSON SAX Precise) | 0.451±0.001 | 113.02±00.01 + 0.00±00.00 | 19.37±00.14 |
Go (jsoniter) | 0.517±0.003 | 230.90±00.03 + 1.35±00.18 | 21.68±00.15 |
Node.js | 0.552±0.002 | 152.51±00.05 + 187.99±00.47 | 25.65±00.06 |
C#/.NET Core (System.Text.Json) | 0.569±0.001 | 561.19±00.19 + 139.73±00.01 | 25.20±00.08 |
Rust (Serde Untyped) | 0.578±0.001 | 111.60±00.03 + 839.97±00.00 | 23.67±00.11 |
C++/clang++ (RapidJSON SAX) | 0.600±0.000 | 194.64±00.01 + 0.00±00.00 | 23.95±00.06 |
Java (DSL-JSON) | 0.603±0.024 | 259.68±00.36 + 190.97±02.88 | 30.71±00.70 |
V/clang | 0.631±0.000 | 111.45±00.03 + 496.21±00.00 | 26.92±00.13 |
V/gcc | 0.637±0.001 | 111.44±00.04 + 496.21±00.03 | 26.60±00.16 |
Crystal (Pull) | 0.655±0.004 | 113.07±00.01 + 18.41±00.03 | 28.93±00.44 |
Crystal (Schema) | 0.676±0.003 | 113.04±00.04 + 48.84±00.04 | 29.69±00.38 |
Python/pypy | 0.688±0.004 | 280.92±00.08 + 125.74±00.04 | 29.52±00.25 |
C++/clang++ (RapidJSON SAX Precise) | 0.736±0.002 | 194.60±00.04 + 0.00±00.00 | 30.11±00.22 |
Julia (JSON3) | 0.765±0.003 | 443.49±00.12 + 252.04±02.56 | 31.12±00.16 |
Perl (Cpanel::JSON::XS) | 0.778±0.005 | 125.51±00.07 + 402.87±00.01 | 32.36±00.19 |
Go | 0.856±0.000 | 117.05±00.14 + 79.91±00.13 | 34.96±00.15 |
PHP | 0.958±0.002 | 126.54±00.05 + 682.21±00.00 | 39.86±00.14 |
Crystal | 0.966±0.002 | 113.04±00.02 + 392.50±00.02 | 41.41±00.39 |
Nim/clang (Packedjson) | 0.976±0.001 | 112.15±00.01 + 294.42±00.00 | 40.29±00.34 |
Nim/gcc (Packedjson) | 0.995±0.001 | 111.83±00.02 + 294.42±00.00 | 41.30±00.28 |
C#/.NET Core | 1.063±0.007 | 569.35±00.12 + 295.46±00.14 | 47.16±00.46 |
C++/g++ (json-c) | 1.176±0.005 | 113.39±00.08 + 1216.08±00.00 | 48.91±00.17 |
C++/clang++ (json-c) | 1.181±0.007 | 112.68±00.06 + 1216.08±00.00 | 49.16±00.56 |
Clojure | 1.215±0.015 | 460.72±06.56 + 546.03±53.52 | 64.32±00.42 |
Go/gccgo | 1.269±0.002 | 138.83±00.11 + 83.59±00.17 | 53.56±00.42 |
C++/clang++ (Nlohmann) | 1.272±0.007 | 112.52±00.07 + 360.17±00.03 | 54.07±00.55 |
Nim/gcc | 1.336±0.002 | 111.83±00.03 + 919.88±00.00 | 55.94±00.16 |
Nim/clang | 1.344±0.002 | 112.15±00.03 + 925.03±00.00 | 55.50±00.20 |
CPython (UltraJSON) | 1.444±0.002 | 122.17±00.08 + 544.51±01.81 | 53.21±00.20 |
Ruby | 1.449±0.008 | 123.97±00.04 + 263.13±00.02 | 60.95±00.39 |
Ruby (--jit) | 1.449±0.006 | 380.63±00.03 + 263.24±00.01 | 61.11±00.37 |
C++/g++ (Nlohmann) | 1.507±0.002 | 113.38±00.05 + 448.03±00.03 | 61.19±00.43 |
Python | 1.525±0.003 | 120.25±00.10 + 375.17±00.02 | 59.36±00.18 |
F#/.NET Core (System.Text.Json) | 1.601±0.004 | 570.59±00.09 + 232.18±06.44 | 69.79±00.32 |
Ruby (YAJL) | 1.965±0.005 | 123.81±00.04 + 282.68±00.01 | 82.27±00.88 |
D/ldc2 | 2.082±0.001 | 112.86±00.06 + 680.20±00.05 | 86.06±00.50 |
C#/Mono | 2.312±0.040 | 252.46±00.07 + 31.53±00.01 | 96.95±01.22 |
Haskell | 2.539±0.005 | 116.59±00.75 + 697.45±00.73 | 107.60±01.21 |
Rust (jq) | 2.640±0.002 | 113.50±00.04 + 778.25±01.42 | 110.56±01.02 |
Ruby/jruby | 2.930±0.031 | 461.99±01.62 + 841.93±75.18 | 148.36±04.17 |
C++/clang++ (Boost.PropertyTree) | 3.166±0.007 | 194.88±00.04 + 1232.84±00.00 | 130.92±01.68 |
C++/g++ (Boost.PropertyTree) | 3.336±0.004 | 113.22±00.05 + 1440.12±00.03 | 139.30±00.49 |
Vala/gcc | 3.613±0.014 | 114.79±00.03 + 940.47±00.05 | 154.92±00.77 |
Vala/clang | 3.633±0.006 | 114.81±00.05 + 940.45±00.03 | 156.14±00.64 |
D/gdc | 3.660±0.004 | 116.67±00.04 + 681.24±00.12 | 156.47±00.70 |
D/dmd | 4.514±0.003 | 113.37±00.04 + 680.34±00.05 | 177.98±00.69 |
Perl (JSON::Tiny) | 9.382±0.067 | 125.86±00.04 + 528.91±00.03 | 404.50±03.82 |
Ruby/truffleruby (--jvm) | 12.311±0.034 | 505.03±05.57 + 2467.82±54.26 | 747.19±05.43 |
Ruby/truffleruby | 22.970±0.503 | 451.72±03.63 + 2314.87±07.88 | 1119.70±23.10 |
Matmul
Testing allocating and multiplying matrices.
Language | Time, s | Memory, MiB | Energy, J |
---|---|---|---|
D/ldc2 (lubeck) | 0.043±0.000 | 6.06±00.02 + 57.94±00.12 | 4.41±00.02 |
V/gcc (VSL + CBLAS) | 0.047±0.000 | 6.96±00.02 + 58.03±00.00 | 4.55±00.04 |
V/clang (VSL + CBLAS) | 0.047±0.000 | 7.03±00.05 + 57.93±00.05 | 4.57±00.02 |
Nim/gcc (Arraymancer) | 0.066±0.004 | 4.91±00.04 + 57.94±00.17 | 5.47±00.28 |
Python (NumPy) | 0.067±0.000 | 30.07±00.04 + 58.18±00.05 | 6.27±00.06 |
Nim/clang (Arraymancer) | 0.069±0.002 | 6.24±00.10 + 57.58±00.12 | 6.02±00.48 |
C++/g++ (Eigen) | 0.072±0.002 | 31.90±06.49 + 58.05±06.57 | 5.39±00.10 |
C++/clang++ (Eigen) | 0.072±0.003 | 36.08±05.02 + 54.22±05.03 | 5.90±00.13 |
Java (ND4J) | 0.079±0.002 | 106.62±01.24 + 91.92±00.12 | 6.18±00.16 |
Rust (ndarray) | 0.089±0.001 | 2.39±00.05 + 68.47±00.00 | 6.05±00.11 |
Julia (threads: 2) | 0.137±0.000 | 237.36±00.09 + 52.34±00.39 | 7.19±00.05 |
Julia (threads: 1) | 0.187±0.000 | 237.13±00.04 + 52.82±00.46 | 8.46±00.04 |
V/clang (VSL) | 0.242±0.005 | 7.04±00.09 + 51.83±00.00 | 17.31±00.37 |
V/gcc (VSL) | 0.477±0.001 | 7.06±00.04 + 51.82±00.00 | 32.25±00.08 |
Julia (no BLAS) | 1.052±0.021 | 224.75±00.14 + 51.52±00.02 | 46.61±00.88 |
D/ldc2 | 1.718±0.003 | 3.27±00.02 + 70.46±00.03 | 63.13±00.15 |
D/gdc | 1.870±0.002 | 6.83±00.03 + 70.88±00.07 | 73.06±00.14 |
D/dmd | 1.874±0.001 | 3.58±00.03 + 70.48±00.02 | 71.02±00.09 |
C/gcc | 3.029±0.000 | 1.47±00.03 + 68.70±00.03 | 109.60±00.60 |
V/gcc | 3.038±0.001 | 2.13±00.03 + 69.01±00.00 | 112.35±00.44 |
V/clang | 3.060±0.000 | 2.43±00.02 + 68.95±00.03 | 104.62±00.04 |
Vala/clang | 3.061±0.000 | 3.93±00.08 + 69.80±00.11 | 104.74±00.17 |
C/clang | 3.062±0.000 | 1.46±00.02 + 68.73±00.05 | 104.49±00.11 |
Rust | 3.065±0.000 | 2.11±00.04 + 68.57±00.00 | 105.21±00.14 |
Zig | 3.074±0.001 | 1.50±00.07 + 68.89±00.03 | 108.77±00.55 |
Nim/gcc | 3.090±0.000 | 2.51±00.02 + 66.26±00.00 | 111.06±00.60 |
Java | 3.093±0.004 | 39.19±00.08 + 68.43±00.16 | 109.77±01.88 |
Swift | 3.095±0.000 | 7.30±00.04 + 68.92±00.02 | 109.29±00.43 |
Nim/clang | 3.122±0.001 | 2.82±00.03 + 66.00±00.00 | 106.98±00.17 |
Vala/gcc | 3.126±0.001 | 3.89±00.02 + 69.86±00.02 | 114.22±00.23 |
Go | 3.153±0.001 | 3.85±00.04 + 73.12±00.11 | 113.47±00.19 |
Go/gccgo | 3.160±0.001 | 24.62±00.01 + 73.50±00.10 | 112.00±00.14 |
Crystal | 3.161±0.000 | 3.44±00.04 + 59.97±00.04 | 115.46±00.14 |
Node.js | 3.238±0.003 | 47.55±00.19 + 76.79±00.11 | 130.43±00.45 |
Python/pypy | 3.274±0.001 | 61.70±00.04 + 68.69±00.06 | 136.27±00.85 |
Scala | 3.325±0.008 | 65.60±00.29 + 140.85±00.30 | 121.60±00.97 |
Kotlin/JVM | 3.664±0.003 | 40.44±00.17 + 68.06±00.29 | 152.07±01.68 |
C#/.NET Core | 4.384±0.001 | 106.09±00.16 + 69.06±00.00 | 175.92±00.95 |
C#/Mono | 7.414±0.001 | 25.41±00.05 + 69.60±00.04 | 299.70±01.56 |
Ruby/truffleruby | 17.828±2.987 | 380.74±06.95 + 518.10±27.76 | 660.11±94.70 |
Ruby/truffleruby (--jvm) | 28.869±0.417 | 552.53±21.56 + 367.72±55.70 | 994.44±18.01 |
Ruby | 198.042±0.817 | 14.98±00.04 + 69.05±00.01 | 8578.84±83.38 |
Ruby (--jit) | 198.618±1.593 | 271.64±00.04 + 72.66±00.01 | 8637.61±80.58 |
Perl | 225.366±0.521 | 9.57±00.03 + 599.64±00.07 | 9143.92±52.78 |
Python | 278.785±0.562 | 10.71±00.27 + 68.87±00.27 | 11177.48±38.78 |
Tcl | 335.868±4.545 | 7.32±00.05 + 400.18±00.00 | 14014.34±226.31 |
Ruby/jruby | 399.505±23.779 | 268.81±01.64 + 756.38±38.36 | 16344.90±758.83 |
Primes
Testing:
- generating primes using the optimized sieve of Atkin;
- prefix search for their decimal numbers using Trie data structure.
Notes:
- All languages but V and Python use unordered hashmaps (V and Python don't provide those out of box, and their hashmaps use keys in the insertion order);
- The results are always sorted (could be unstable or stable though).
Language | Time, s | Memory, MiB | Energy, J |
---|---|---|---|
C++/g++ | 0.071±0.000 | 3.68±00.04 + 77.91±00.26 | 2.71±00.02 |
Zig | 0.072±0.000 | 0.91±00.02 + 57.81±00.03 | 2.97±00.03 |
C++/clang++ | 0.072±0.000 | 1.65±00.05 + 61.74±00.35 | 2.70±00.02 |
V/clang | 0.106±0.000 | 1.91±00.04 + 212.02±00.30 | 4.25±00.01 |
V/gcc | 0.107±0.000 | 1.87±00.05 + 208.57±00.33 | 4.35±00.03 |
Rust | 0.115±0.000 | 0.94±00.01 + 74.00±00.01 | 4.47±00.06 |
Crystal | 0.151±0.000 | 2.88±00.06 + 89.06±00.05 | 6.01±00.03 |
Java | 0.164±0.002 | 38.52±00.14 + 153.60±05.25 | 9.25±00.20 |
Node.js | 0.225±0.002 | 42.34±00.13 + 150.08±00.35 | 11.26±00.08 |
Nim/clang | 0.298±0.000 | 1.99±00.03 + 598.51±01.16 | 11.77±00.05 |
Scala | 0.299±0.006 | 67.35±00.22 + 148.34±04.80 | 15.31±00.13 |
Nim/gcc | 0.324±0.031 | 1.69±00.02 + 599.54±15.34 | 12.39±01.06 |
Lua/luajit | 0.338±0.002 | 1.21±00.03 + 157.08±00.75 | 13.26±00.21 |
Julia | 0.593±0.000 | 226.44±00.06 + 376.93±00.44 | 23.15±00.20 |
Python/pypy | 0.830±0.002 | 59.75±00.10 + 251.87±00.06 | 32.55±00.20 |
Ruby/truffleruby (--jvm) | 1.221±0.033 | 409.10±02.87 + 542.80±45.51 | 79.93±02.22 |
Ruby (--jit) | 1.442±0.004 | 270.68±00.04 + 146.96±00.01 | 58.58±00.76 |
Lua | 1.493±0.004 | 2.28±00.05 + 284.23±00.90 | 58.17±00.36 |
Ruby/truffleruby | 1.657±0.050 | 299.73±00.64 + 496.36±29.59 | 92.44±02.52 |
Ruby | 2.063±0.011 | 13.96±00.03 + 146.97±00.02 | 83.40±00.73 |
Ruby/jruby | 2.143±0.020 | 187.79±00.61 + 545.57±11.80 | 111.13±02.43 |
Python | 4.984±0.041 | 10.42±00.03 + 234.84±00.78 | 194.67±02.44 |
Tests Execution
Environment
CPU: Intel(R) Xeon(R) E-2324G
Base Docker image: Debian GNU/Linux bookworm/sid
Language | Version |
---|---|
.NET Core | 7.0.100 |
C#/.NET Core | 4.4.0-4.22520.11 (9e075f03) |
C#/Mono | 6.8.0.105 |
Chez Scheme | 9.5.8 |
Clojure | "1.11.1" |
Crystal | 1.6.2 |
D/dmd | v2.101.0 |
D/gdc | 12.2.0 |
D/ldc2 | 1.30.0 |
Elixir | 1.14.0 |
F#/.NET Core | 12.4.0.0 for F# 7.0 |
Go | go1.19.4 |
Go/gccgo | 12.2.0 |
Haskell | 9.4.3 |
Idris 2 | 0.6.0 |
Java | 19.0.1 |
Julia | v"1.8.3" |
Kotlin | 1.7.21 |
Lua | 5.4.4 |
Lua/luajit | 2.1.0-beta3 |
MLton | 20210117 |
Nim | 1.6.10 |
Node.js | v19.2.0 |
OCaml | 4.14.0 |
PHP | 8.1.12 |
Perl | v5.36.0 |
Python | 3.10.8 |
Python/pypy | 7.3.10-final0 for Python 3.9.15 |
Racket | "8.7" |
Ruby | 3.1.3p185 |
Ruby/jruby | 9.4.0.0 |
Ruby/truffleruby | 22.3.0 |
Rust | 1.65.0 |
Scala | 3.2.1 |
Swift | 5.7.1 |
Tcl | 8.6 |
V | 0.3.2 d62fc77 |
Vala | 0.56.3 |
Zig | 0.10.0 |
clang/clang++ | 14.0.6 |
gcc/g++ | 12.2.0 |
Using Docker
Build the image:
$ docker build docker/ -t benchmarks
The pinned packages could be missing, in that case please update them with:
$ ./run.sh update_apt
Run the image:
$ docker run -it --rm -v $(pwd):/src benchmarks <cmd>
where <cmd>
is:
versions
(print installed language versions);shell
(start the shell);brainfuck bench
(build and run Brainfuck bench.b benchmarks);brainfuck mandel
(build and run Brainfuck mandel.b benchmarks);base64
(build and run Base64 benchmarks);json
(build and run Json benchmarks);matmul
(build and run Matmul benchmarks);primes
(build and run Primes benchmarks);
Please note that the actual measurements provided in the project are taken semi-manually (via shell
) as the full update takes days and could have occassional issues in Docker.
There is a ./run.sh
that could be used to simplify Docker usage:
./run.sh build
(build the image);./run.sh make versions
(run the image with theversions
command);sudo ./run.sh shell
(run the image with the `shell' command, sudo is required to read energy levels).
Manual Execution
Makefiles contain recipes for building and executing tests with the
proper dependencies. Please use make run
(and make run2
where applicable).
The measurements are taken using analyze.rb
script:
$ cd <test suite>
$ ../analyze.rb make run
$ ../analyze.rb make run[<single test>]
Please note that the measurements could take hours. It uses 10 iterations by default, but it could be changed using ATTEMPTS environment variable:
$ ATTEMPTS=1 ../analyze.rb make run
Prerequisites
Please use Dockerfile as a reference regarding which packages and tools are required.
For all (optional):
- Powercap for reading energy
counters in Linux (Debian package
powercap-utils
).
For Python:
- NumPy for matmul tests
(Debian package
python3-numpy
). - UltraJSON for JSON tests
(Debian package
python3-ujson
).
For C++:
- Boost for JSON tests
(Debian package
libboost-dev
). - JSON-C for JSON tests
(Debian package
libjson-c-dev
).
For Rust:
- libjq for jq test
(Debian packages
libjq-dev
,libonig-dev
and environment variableJQ_LIB_DIR=/usr/lib/x86_64-linux-gnu/
).
For Java, Scala:
- Coursier for downloading Maven artifacts.
For Haskell:
- network for TCP connectivity between the tests and the test runner.
- raw-strings-qq for raw string literals used in tests.
For Perl:
- cpanminus for installing
modules from CPAN (Debian package
cpanminus
).
For Vala:
- JSON-GLib for JSON tests
(Debian package
libjson-glib-dev
).
Contribution
Please follow the criteria specified in the overview. Besides that please ensure that the communication protocol between a test and the test runner is satisfied:
- The test runner listens on localhost:9001;
- All messages are sent using TCP sockets closed immediately after the message has been sent;
- There are two messages sent from a test (it establishes the measurement
boundary):
- The beginning message having the format name of the test/tprocess ID (the process ID is used to measure the memory consumption). Please note that the name of the test couldn't use Tab character as it's a delimiter;
- The end message with any content (mostly it's "stop" for consistency).
- The test runner could be unavailable (if the test is launched as is) and the test should gracefully handle it.
Makefile guide
Binary executables
If the test is compiled into a single binary, then two sections of
the Makefile
require changes:
- append a new target (the final binary location) into
executables
variable; - append the proper target rule.
Compiled artifacts
If the test is compiled, but can't be executed directly as a binary, then
three sections of the Makefile
require changes:
- append a new target (the final artifact location) into
artifacts
variable; - append the proper target rule to compile the test;
- append
run[<target_artifact>]
rule to run the test.
Scripting language
If the test doesn't require compilation, then two sections of the Makefile
requires changes:
- append
run[<script_file>]
intoall_runners
variable; - append
run[<script_file>]
rule to run the test.
README update
TOC is regenerated using git-markdown-toc:
./run.sh toc
Docker image update
Debian packages are pinned and updated with the script (first, please ensure that the image is fine with the linter):
./run.sh lint
./run.sh update_apt