D VS Nim benchmarks

Current benchmark data was generated on Mon Feb 06 2023, full log can be found HERE

CONTRIBUTIONS are WELCOME!

[x86_64][2 cores] Intel(R) Xeon(R) Platinum 8272CL CPU @ 2.60GHz (Model 85)

* -m in a file name stands for multi-threading or multi-processing

* -i in a file name stands for direct intrinsics usage. (Usage of simd intrinsics via libraries is not counted)

* -ffi in a file name stands for non-stdlib FFI usage

* (You may find time < time(user) + time(sys) for some non-parallelized programs, the overhead is from GC or JIT compiler, which are allowed to take advantage of multi-cores as that's more close to real-world scenarios.)

binarytrees

Input: 18

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 2.nim 2133ms 3.3ms 33.6MB 2107ms 13ms nim 1.6.10
nim 2.nim 2138ms 5.8ms 35.0MB 2120ms 3ms nim/clang 1.6.10
d 1.d 3392ms 64ms 74.9MB 3630ms 33ms ldc2 1.30.0
d 1.d 4652ms 28ms 154.1MB 5177ms 33ms dmd 2.102.0

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 2.nim 201ms 0.2ms 5.7MB 190ms 0ms nim/clang 1.6.10
nim 2.nim 202ms 1.0ms 5.6MB 190ms 0ms nim 1.6.10
d 1.d 306ms 5.6ms 15.1MB 287ms 7ms ldc2 1.30.0
d 1.d 394ms 1.4ms 27.1MB 410ms 0ms dmd 2.102.0

coro-prime-sieve

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
d 1.d timeout 0.0ms 14.4MB 4963ms 17ms dmd 2.102.0
d 1.d timeout 0.0ms 13.4MB 4963ms 17ms ldc2 1.30.0
nim 1.nim timeout 0.0ms 429.3MB 3407ms 1243ms nim 1.6.10
nim 1.nim timeout 0.0ms 432.9MB 3397ms 1250ms nim/clang 1.6.10

Input: 1000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
d 1.d 1272ms 6.8ms 8.4MB 1247ms 10ms ldc2 1.30.0
d 1.d 1655ms 8.1ms 10.0MB 1640ms 3ms dmd 2.102.0
nim 1.nim timeout 0.0ms 431.1MB 3390ms 1257ms nim 1.6.10
nim 1.nim timeout 0.0ms 433.4MB 3370ms 1273ms nim/clang 1.6.10

edigits

Input: 250001

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
d 1.d timeout 0.0ms 9.4MB 4980ms 0ms dmd 2.102.0
d 1.d timeout 0.0ms 7.6MB 4980ms 0ms ldc2 1.30.0
nim 1.nim timeout 0.0ms 3.0MB 4983ms 0ms nim 1.6.10
nim 1.nim timeout 0.0ms 3.0MB 4987ms 0ms nim/clang 1.6.10

Input: 100000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
d 1.d 919ms 0.8ms 7.3MB 910ms 0ms ldc2 1.30.0
d 1.d 1055ms 0.3ms 8.7MB 1050ms 0ms dmd 2.102.0
nim 1.nim timeout 0.0ms 2.3MB 4990ms 0ms nim 1.6.10
nim 1.nim timeout 0.0ms 2.2MB 4990ms 0ms nim/clang 1.6.10

fannkuch-redux

Input: 11

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
d 1-im.d 670ms 7.6ms 1.6MB 1260ms 0ms ldc2 1.30.0
d 1-i.d 1256ms 8.5ms 1.5MB 1240ms 0ms ldc2 1.30.0
d 2-im.d 2556ms 2.4ms 1.6MB 4943ms 0ms ldc2 1.30.0
d 1.d 4106ms 20ms 1.5MB 4097ms 0ms ldc2 1.30.0
d 1.d 4235ms 1.1ms 2.7MB 4220ms 0ms dmd 2.102.0
d 2-i.d 4884ms 4.9ms 1.5MB 4870ms 0ms ldc2 1.30.0
d 1-i.d timeout 0.0ms 2.1MB 4987ms 0ms dmd 2.102.0
d 1-im.d timeout 0.0ms 2.7MB 9817ms 0ms dmd 2.102.0
d 2-i.d timeout 0.0ms 2.7MB 4987ms 0ms dmd 2.102.0
d 2-im.d timeout 0.0ms 2.6MB 9470ms 0ms dmd 2.102.0

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
d 1-im.d 66ms 1.8ms 3.1MB 100ms 0ms ldc2 1.30.0
d 1-i.d 108ms 1.1ms 1.5MB 100ms 0ms ldc2 1.30.0
d 2-im.d 221ms 6.2ms 1.5MB 397ms 0ms ldc2 1.30.0
d 1.d 327ms 3.7ms 1.5MB 313ms 0ms ldc2 1.30.0
d 1.d 353ms 0.8ms 2.7MB 340ms 0ms dmd 2.102.0
d 2-i.d 403ms 0.4ms 1.6MB 390ms 0ms ldc2 1.30.0
d 1-im.d 461ms 3.1ms 2.6MB 860ms 0ms dmd 2.102.0
d 2-im.d 760ms 2.3ms 2.6MB 1440ms 0ms dmd 2.102.0
d 1-i.d 863ms 4.3ms 2.2MB 850ms 0ms dmd 2.102.0
d 2-i.d 1378ms 2.0ms 2.6MB 1367ms 0ms dmd 2.102.0

fasta

Input: 2500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
d 1.d 216ms 0.6ms 30.7MB 190ms 10ms ldc2 1.30.0
nim 2.nim 242ms 0.5ms 1.0MB 227ms 0ms nim 1.6.10
nim 2.nim 308ms 2.2ms 1.3MB 300ms 0ms nim/clang 1.6.10
d 1.d 678ms 0.8ms 39.9MB 657ms 7ms dmd 2.102.0
nim 1.nim 690ms 3.1ms 1.2MB 593ms 80ms nim/clang 1.6.10
nim 1.nim 712ms 0.9ms 1.0MB 607ms 90ms nim 1.6.10

Input: 250000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
d 1.d 26ms 0.9ms 8.9MB 17ms 0ms ldc2 1.30.0
nim 2.nim 26ms 0.8ms 1.1MB 20ms 0ms nim 1.6.10
nim 2.nim 34ms 0.4ms 1.2MB 23ms 0ms nim/clang 1.6.10
d 1.d 71ms 0.2ms 10.6MB 60ms 0ms dmd 2.102.0
nim 1.nim 72ms 1.4ms 1.2MB 53ms 3ms nim/clang 1.6.10
nim 1.nim 74ms 0.4ms 1.0MB 60ms 0ms nim 1.6.10

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 1.nim 1.4ms 0.5ms 1.0MB 0ms 0ms nim 1.6.10
nim 1.nim 1.7ms 0.5ms 1.3MB 0ms 0ms nim/clang 1.6.10
d 1.d 2.2ms 0.3ms 4.4MB 0ms 0ms dmd 2.102.0
d 1.d 2.7ms 0.8ms 2.8MB 0ms 0ms ldc2 1.30.0

json-serde

Input: sample 5000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
d 2.d 75ms 3.1ms 15.5MB 67ms 3ms ldc2 1.30.0
d 2.d 291ms 1.1ms 21.5MB 277ms 7ms dmd 2.102.0

Input: canada 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
d 2.d 608ms 2.1ms 139.8MB 543ms 43ms ldc2 1.30.0
d 2.d 3142ms 1.9ms 157.1MB 3140ms 50ms dmd 2.102.0

knucleotide

Input: 2500000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
d 1-m.d 1552ms 47ms 51.1MB 2807ms 13ms ldc2 1.30.0
d 1-m.d 3770ms 69ms 52.6MB 7183ms 13ms dmd 2.102.0

Input: 250000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
d 1-m.d 188ms 15ms 40.1MB 313ms 7ms ldc2 1.30.0
d 1-m.d 420ms 13ms 42.2MB 747ms 13ms dmd 2.102.0

lru

Input: 1000 1000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 2.nim 149ms 0.3ms 1.3MB 140ms 0ms nim/clang 1.6.10
nim 2.nim 152ms 0.1ms 1.0MB 140ms 0ms nim 1.6.10
d 1.d 174ms 0.7ms 3.7MB 167ms 0ms ldc2 1.30.0
d 1.d 249ms 1.3ms 5.3MB 240ms 0ms dmd 2.102.0
nim 1.nim timeout 0.0ms 1.0MB 4990ms 0ms nim 1.6.10
nim 1.nim timeout 0.0ms 1.3MB 4983ms 0ms nim/clang 1.6.10

Input: 1000 3000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 2.nim 440ms 0.3ms 1.2MB 430ms 0ms nim/clang 1.6.10
nim 2.nim 451ms 0.0ms 1.0MB 440ms 0ms nim 1.6.10
d 1.d 509ms 1.6ms 3.7MB 497ms 0ms ldc2 1.30.0
d 1.d 743ms 15ms 5.4MB 733ms 0ms dmd 2.102.0
nim 1.nim timeout 0.0ms 1.1MB 4987ms 0ms nim 1.6.10
nim 1.nim timeout 0.0ms 1.3MB 4987ms 0ms nim/clang 1.6.10

Input: 100 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 2.nim 65ms 0.4ms 1.2MB 53ms 0ms nim/clang 1.6.10
nim 2.nim 66ms 0.7ms 1.0MB 60ms 0ms nim 1.6.10
d 1.d 75ms 0.9ms 3.7MB 70ms 0ms ldc2 1.30.0
d 1.d 110ms 0.8ms 5.1MB 100ms 0ms dmd 2.102.0
nim 1.nim 388ms 6.2ms 1.3MB 377ms 0ms nim/clang 1.6.10
nim 1.nim 438ms 20ms 1.0MB 427ms 0ms nim 1.6.10

mandelbrot

Input: 5000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 1.nim 587ms 5.9ms 4.8MB 573ms 0ms nim/clang 1.6.10
d 1.d 608ms 2.6ms 7.1MB 593ms 0ms ldc2 1.30.0
nim 1.nim 869ms 0.8ms 4.5MB 860ms 0ms nim 1.6.10
d 1.d 2901ms 193ms 7.9MB 2887ms 0ms dmd 2.102.0

Input: 1000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 1.nim 27ms 0.5ms 1.2MB 20ms 0ms nim/clang 1.6.10
d 1.d 28ms 0.4ms 3.0MB 20ms 0ms ldc2 1.30.0
nim 1.nim 39ms 1.5ms 1.1MB 30ms 0ms nim 1.6.10
d 1.d 118ms 0.5ms 3.7MB 110ms 0ms dmd 2.102.0

merkletrees

Input: 17

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 1.nim 1081ms 3.0ms 34.6MB 1060ms 3ms nim/clang 1.6.10
nim 1.nim 1089ms 2.4ms 34.6MB 1063ms 7ms nim 1.6.10
d 1.d 1591ms 1.6ms 74.8MB 1653ms 17ms ldc2 1.30.0
d 1.d 2722ms 3.1ms 154.0MB 3030ms 40ms dmd 2.102.0

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 1.nim 230ms 0.3ms 9.3MB 217ms 0ms nim 1.6.10
nim 1.nim 230ms 0.9ms 9.5MB 217ms 0ms nim/clang 1.6.10
d 1.d 316ms 1.9ms 38.9MB 293ms 10ms ldc2 1.30.0
d 1.d 560ms 4.4ms 40.4MB 600ms 3ms dmd 2.102.0

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 2.nim 404ms 0.9ms 1.3MB 390ms 0ms nim 1.6.10
nim 2.nim 415ms 13ms 1.2MB 403ms 0ms nim/clang 1.6.10
d 1.d 463ms 0.1ms 1.6MB 450ms 0ms ldc2 1.30.0
d 2.d 468ms 1.8ms 1.6MB 457ms 0ms ldc2 1.30.0
d 1.d 1242ms 0.2ms 2.7MB 1230ms 0ms dmd 2.102.0
d 2.d 2199ms 6.7ms 2.6MB 2190ms 0ms dmd 2.102.0

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 2.nim 43ms 0.7ms 1.3MB 30ms 0ms nim 1.6.10
nim 2.nim 44ms 0.9ms 1.3MB 30ms 0ms nim/clang 1.6.10
d 1.d 49ms 0.3ms 1.5MB 40ms 0ms ldc2 1.30.0
d 2.d 51ms 0.2ms 1.6MB 40ms 0ms ldc2 1.30.0
d 1.d 127ms 0.3ms 2.6MB 117ms 0ms dmd 2.102.0
d 2.d 224ms 2.2ms 2.6MB 210ms 0ms dmd 2.102.0

nsieve

Input: 12

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 2.nim 689ms 7.0ms 6.3MB 677ms 0ms nim/clang 1.6.10
nim 2.nim 838ms 3.1ms 6.0MB 827ms 0ms nim 1.6.10
d 2.d 851ms 3.2ms 48.4MB 813ms 23ms ldc2 1.30.0
d 1.d 973ms 36ms 75.3MB 937ms 17ms dmd 2.102.0
nim 1.nim 1031ms 44ms 40.6MB 1010ms 10ms nim 1.6.10
d 1.d 1253ms 18ms 42.4MB 1220ms 13ms ldc2 1.30.0
nim 1.nim 1316ms 20ms 41.3MB 1290ms 10ms nim/clang 1.6.10
d 2.d 1558ms 2.0ms 49.9MB 1530ms 10ms dmd 2.102.0

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 1.nim 122ms 2.5ms 11.1MB 107ms 0ms nim 1.6.10
d 1.d 129ms 7.2ms 13.4MB 113ms 0ms ldc2 1.30.0
d 1.d 140ms 1.8ms 24.6MB 127ms 3ms dmd 2.102.0
nim 1.nim 142ms 1.3ms 11.2MB 130ms 0ms nim/clang 1.6.10
nim 2.nim 154ms 1.1ms 3.3MB 140ms 0ms nim/clang 1.6.10
d 2.d 196ms 1.4ms 15.1MB 180ms 0ms ldc2 1.30.0
nim 2.nim 198ms 0.5ms 3.1MB 183ms 0ms nim 1.6.10
d 2.d 386ms 0.7ms 16.1MB 370ms 0ms dmd 2.102.0

pidigits

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
d 1.d 3024ms 5.6ms 7.8MB 3013ms 20ms ldc2 1.30.0
d 1.d timeout 0.0ms 9.4MB 5000ms 7ms dmd 2.102.0
nim 1.nim timeout 0.0ms 5.8MB 4980ms 0ms nim 1.6.10
nim 1.nim timeout 0.0ms 5.8MB 4983ms 0ms nim/clang 1.6.10

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
d 1.d 729ms 3.5ms 7.9MB 717ms 0ms ldc2 1.30.0
d 1.d 1409ms 1.1ms 9.4MB 1393ms 7ms dmd 2.102.0
nim 1.nim timeout 0.0ms 5.9MB 4987ms 0ms nim 1.6.10
nim 1.nim timeout 0.0ms 5.8MB 4983ms 3ms nim/clang 1.6.10

regex-redux

Input: 2500000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
d 3.d 765ms 5.5ms 170.8MB 933ms 60ms ldc2 1.30.0
d 3.d 1684ms 8.3ms 171.4MB 1860ms 63ms dmd 2.102.0
nim 1.nim 2436ms 0.3ms 167.9MB 2367ms 47ms nim/clang 1.6.10
nim 1.nim 2487ms 3.3ms 167.2MB 2417ms 50ms nim 1.6.10

Input: 250000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
d 3.d 84ms 1.7ms 24.9MB 83ms 7ms ldc2 1.30.0
d 3.d 176ms 3.3ms 25.3MB 183ms 0ms dmd 2.102.0
nim 1.nim 249ms 1.1ms 17.1MB 237ms 0ms nim/clang 1.6.10
nim 1.nim 255ms 1.2ms 16.8MB 237ms 3ms nim 1.6.10

secp256k1

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
d 1.d timeout 0.0ms 6.0MB 5003ms 0ms dmd 2.102.0
d 1.d timeout 0.0ms 3.7MB 4987ms 13ms ldc2 1.30.0

Input: 500

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
d 1.d 1514ms 25ms 3.7MB 1500ms 7ms ldc2 1.30.0
d 1.d 2995ms 5.5ms 6.0MB 2987ms 0ms dmd 2.102.0

spectral-norm

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 1.nim 3433ms 1.3ms 1.3MB 3420ms 0ms nim/clang 1.6.10
nim 1.nim 3434ms 1.2ms 1.3MB 3420ms 0ms nim 1.6.10
d 1.d 3633ms 1.8ms 3.8MB 3620ms 0ms ldc2 1.30.0
d 1.d 4206ms 8.2ms 5.5MB 4187ms 3ms dmd 2.102.0

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 1.nim 861ms 0.6ms 1.3MB 847ms 0ms nim 1.6.10
nim 1.nim 862ms 1.6ms 1.3MB 850ms 0ms nim/clang 1.6.10
d 1.d 913ms 2.2ms 3.6MB 900ms 0ms ldc2 1.30.0
d 1.d 1054ms 0.3ms 4.7MB 1040ms 0ms dmd 2.102.0

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
nim 1.nim 217ms 0.3ms 1.3MB 207ms 0ms nim/clang 1.6.10
nim 1.nim 218ms 0.4ms 1.3MB 207ms 0ms nim 1.6.10
d 1.d 232ms 1.2ms 3.2MB 220ms 0ms ldc2 1.30.0
d 1.d 268ms 1.9ms 4.2MB 257ms 0ms dmd 2.102.0