V VS Java benchmarks

Current benchmark data was generated on Sat Jan 28 2023, full log can be found HERE

CONTRIBUTIONS are WELCOME!

[x86_64][2 cores] Intel(R) Xeon(R) Platinum 8370C CPU @ 2.80GHz (Model 106)

* -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
java 2.java 665ms 6.1ms 412.0MB 690ms 70ms openjdk 20
java 2.java 719ms 58ms 602.2MB 703ms 117ms openjdk 19
java 2.java 760ms 59ms 667.2MB 823ms 147ms graal/jvm 17.0.6
java 2.java 1276ms 25ms 1068.3MB 903ms 577ms openjdk/zgc 19
v 1.v 1286ms 4.6ms 37.1MB 1260ms 13ms v/clang+gc 0.3.2
v 1.v 1296ms 49ms 37.2MB 1277ms 3ms v/clang 0.3.2

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
v 1.v 94ms 1.4ms 5.6MB 83ms 0ms v/clang+gc 0.3.2
v 1.v 95ms 1.3ms 5.5MB 83ms 0ms v/clang 0.3.2
java 2.java 167ms 1.7ms 109.0MB 167ms 30ms openjdk 19
java 2.java 169ms 16ms 108.4MB 163ms 20ms openjdk 20
java 2-m.java 172ms 3.9ms 157.8MB 217ms 43ms graal/jvm 17.0.6
java 2.java 295ms 1.6ms 248.7MB 197ms 137ms openjdk/zgc 19

coro-prime-sieve

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
java 1-m.java 1079ms 1868ms 169.2MB 8467ms 113ms openjdk 19
java 1-m.java 4163ms 65ms 906.7MB 7423ms 537ms openjdk/zgc 19
java 1.java timeout 0.0ms 139.7MB 9567ms 47ms openjdk 20
v 1.v timeout 0.0ms 16.6MB 5250ms 4327ms v/clang 0.3.2
v 1.v timeout 0.0ms 21.1MB 5033ms 4270ms v/clang+gc 0.3.2

Input: 1000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
java 1-m.java 766ms 114ms 112.0MB 1377ms 37ms openjdk 20
java 1-m.java 817ms 154ms 113.2MB 1453ms 47ms openjdk 19
java 1-m.java 950ms 24ms 315.6MB 1520ms 173ms openjdk/zgc 19
v 1-m.v 3602ms 203ms 24.5MB 3690ms 3160ms v/clang+gc 0.3.2
v 1-m.v 3937ms 909ms 16.5MB 3953ms 3430ms v/clang 0.3.2

edigits

Input: 250001

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
java 1-m.java 778ms 13ms 204.8MB 1363ms 63ms openjdk 20
java 1-m.java 846ms 64ms 301.8MB 1367ms 70ms graal/jvm 17.0.6
java 1-m.java 877ms 15ms 199.6MB 1570ms 57ms openjdk 19
java 1-m.java 1013ms 13ms 429.1MB 1507ms 290ms openjdk/zgc 19
v 1.v timeout 0.0ms 28.8MB 4983ms 0ms v/clang+gc 0.3.2

Input: 100000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
java 1-m.java 367ms 12ms 159.9MB 603ms 50ms graal/jvm 17.0.6
java 1-m.java 441ms 18ms 118.0MB 737ms 23ms openjdk 19
java 1-m.java 466ms 5.9ms 115.5MB 780ms 40ms openjdk 20
java 1-m.java 550ms 40ms 209.2MB 790ms 137ms openjdk/zgc 19
v 1.v timeout 0.0ms 12.8MB 4973ms 0ms v/clang+gc 0.3.2

fannkuch-redux

Input: 11

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
java 1-m.java 1668ms 10ms 95.1MB 3183ms 20ms graal/jvm 17.0.6
java 1-m.java 1741ms 6.4ms 43.8MB 3257ms 50ms openjdk/zgc 19
java 1-m.java 1751ms 36ms 43.7MB 3357ms 20ms openjdk 19
java 1-m.java 1789ms 119ms 41.1MB 3427ms 10ms openjdk 20
v 1.v 3313ms 2.1ms 2.0MB 3297ms 0ms v/clang+gc 0.3.2
v 1.v 3325ms 8.4ms 2.0MB 3310ms 0ms v/clang 0.3.2

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
java 1-m.java 277ms 4.7ms 43.6MB 440ms 20ms openjdk 19
java 1-m.java 278ms 2.5ms 40.5MB 453ms 7ms openjdk 20
v 1.v 280ms 0.9ms 2.0MB 270ms 0ms v/clang 0.3.2
java 1-m.java 283ms 4.5ms 90.9MB 463ms 10ms graal/jvm 17.0.6
v 1.v 289ms 14ms 2.0MB 273ms 0ms v/clang+gc 0.3.2
java 1-m.java 321ms 3.3ms 43.8MB 440ms 57ms openjdk/zgc 19

fasta

Input: 2500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
java 4.java 515ms 1.8ms 40.7MB 587ms 10ms openjdk 20
java 4.java 523ms 4.9ms 42.2MB 587ms 17ms openjdk 19
java 4.java 561ms 7.1ms 43.3MB 583ms 57ms openjdk/zgc 19
java 4.java 617ms 8.7ms 99.3MB 793ms 30ms graal/jvm 17.0.6
v 1.v 651ms 2.0ms 2.0MB 633ms 0ms v/clang+gc 0.3.2
v 1.v 653ms 3.2ms 2.0MB 637ms 0ms v/clang 0.3.2

Input: 250000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
v 1.v 68ms 0.6ms 2.0MB 60ms 0ms v/clang+gc 0.3.2
v 1.v 70ms 1.7ms 2.1MB 60ms 0ms v/clang 0.3.2
java 4.java 151ms 6.6ms 41.0MB 173ms 10ms openjdk 19
java 4.java 155ms 11ms 89.1MB 203ms 17ms graal/jvm 17.0.6
java 4.java 155ms 5.7ms 40.1MB 183ms 7ms openjdk 20
java 4.java 191ms 4.0ms 41.1MB 167ms 50ms openjdk/zgc 19

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
v 1.v 1.8ms 0.6ms 2.0MB 0ms 0ms v/clang+gc 0.3.2
v 1.v 1.8ms 0.6ms 2.1MB 0ms 0ms v/clang 0.3.2
java 1.java 76ms 6.2ms 63.1MB 70ms 10ms graal/jvm 17.0.6
java 1.java 79ms 3.3ms 39.3MB 74ms 10ms openjdk 20
java 1.java 81ms 3.7ms 41.3MB 76ms 8ms openjdk 19
java 1.java 119ms 4.3ms 39.7MB 76ms 48ms openjdk/zgc 19

http-server

Input: 3000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
v 1.v timeout 0.0ms 9.5MB 537ms 797ms v/clang+gc 0.3.2

Input: 500

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
v 1.v 193ms 38ms 14.8MB 87ms 80ms v/clang+gc 0.3.2

lru

Input: 1000 1000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
v 1.v 403ms 1.5ms 2.2MB 390ms 0ms v/clang+gc 0.3.2
v 1.v 424ms 0.3ms 2.2MB 410ms 0ms v/clang 0.3.2

Input: 1000 3000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
v 1.v 1205ms 2.4ms 2.3MB 1193ms 0ms v/clang+gc 0.3.2
v 1.v 1265ms 1.6ms 2.3MB 1257ms 0ms v/clang 0.3.2

Input: 100 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
v 1.v 134ms 1.0ms 2.3MB 123ms 0ms v/clang+gc 0.3.2
v 1.v 140ms 0.3ms 2.3MB 130ms 0ms v/clang 0.3.2

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
java 1.java 542ms 2.3ms 88.2MB 563ms 23ms graal/jvm 17.0.6
java 1.java 565ms 6.7ms 40.5MB 563ms 20ms openjdk 20
java 1.java 568ms 4.5ms 44.3MB 573ms 10ms openjdk 19
java 1.java 613ms 5.8ms 41.9MB 580ms 50ms openjdk/zgc 19
v 1.v 871ms 0.8ms 2.3MB 860ms 0ms v/clang 0.3.2
v 1.v 879ms 6.2ms 2.3MB 863ms 0ms v/clang+gc 0.3.2
java 2.java 1881ms 18ms 552.6MB 1900ms 113ms openjdk 20
java 2.java 1893ms 4.6ms 532.8MB 1910ms 107ms openjdk 19
java 2.java 2574ms 9.2ms 1220.9MB 1993ms 770ms openjdk/zgc 19

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
v 1.v 90ms 0.2ms 2.3MB 80ms 0ms v/clang+gc 0.3.2
v 1.v 91ms 1.3ms 2.3MB 80ms 0ms v/clang 0.3.2
java 1.java 137ms 1.3ms 86.0MB 163ms 23ms graal/jvm 17.0.6
java 1.java 144ms 3.4ms 42.3MB 157ms 10ms openjdk 19
java 1.java 149ms 7.7ms 40.7MB 160ms 10ms openjdk 20
java 1.java 191ms 2.6ms 44.1MB 160ms 50ms openjdk/zgc 19
java 2.java 414ms 6.8ms 335.1MB 487ms 63ms openjdk 19
java 2.java 416ms 8.0ms 338.5MB 477ms 67ms openjdk 20
java 2.java 701ms 44ms 528.8MB 540ms 313ms openjdk/zgc 19

nsieve

Input: 12

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
v 2.v 507ms 3.1ms 11.0MB 497ms 0ms v/clang 0.3.2
v 2.v 510ms 3.1ms 10.7MB 493ms 3ms v/clang+gc 0.3.2
java 1.java 658ms 16ms 85.7MB 683ms 17ms openjdk 19
java 1.java 780ms 41ms 84.9MB 797ms 30ms openjdk 20
java 1.java 906ms 5.7ms 112.0MB 847ms 80ms openjdk/zgc 19
java 2.java 1003ms 6.2ms 50.6MB 1043ms 13ms openjdk 20
java 2.java 1017ms 5.7ms 54.0MB 1050ms 7ms openjdk 19
java 2.java 1027ms 2.0ms 50.5MB 1007ms 57ms openjdk/zgc 19
java 1-m.java 1131ms 52ms 244.6MB 1700ms 87ms graal/jvm 17.0.6
v 1.v 1164ms 113ms 41.1MB 1143ms 7ms v/clang+gc 0.3.2
v 1.v 1352ms 95ms 41.2MB 1330ms 7ms v/clang 0.3.2
java 2-m.java 1840ms 116ms 286.4MB 3240ms 110ms graal/jvm 17.0.6

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
v 2.v 116ms 0.4ms 4.0MB 107ms 0ms v/clang+gc 0.3.2
v 2.v 117ms 0.7ms 4.1MB 107ms 0ms v/clang 0.3.2
v 1.v 122ms 1.8ms 20.0MB 110ms 0ms v/clang+gc 0.3.2
v 1.v 129ms 2.2ms 20.8MB 113ms 0ms v/clang 0.3.2
java 1.java 236ms 3.3ms 61.7MB 253ms 23ms openjdk 19
java 1.java 239ms 7.2ms 58.4MB 260ms 13ms openjdk 20
java 1.java 284ms 2.1ms 60.7MB 260ms 60ms openjdk/zgc 19
java 2.java 327ms 2.5ms 45.1MB 360ms 10ms openjdk 20
java 2.java 328ms 1.3ms 49.7MB 350ms 17ms openjdk 19
java 1-m.java 338ms 2.6ms 149.3MB 483ms 40ms graal/jvm 17.0.6
java 2.java 359ms 6.6ms 43.9MB 343ms 50ms openjdk/zgc 19
java 2-m.java 614ms 3.5ms 152.0MB 1087ms 47ms graal/jvm 17.0.6

pidigits

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
v 1.v 3901ms 88ms 3.2MB 3873ms 10ms v/clang+gc 0.3.2
java 1.java 4919ms 11ms 360.4MB 5340ms 87ms graal/jvm 17.0.6
java 1.java timeout 0.0ms 239.2MB 5423ms 90ms openjdk 19
java 1.java timeout 0.0ms 279.2MB 5390ms 80ms openjdk 20
java 1.java timeout 0.0ms 1254.0MB 5003ms 670ms openjdk/zgc 19
v 1.v timeout 0.0ms 4.0MB 4980ms 7ms v/clang 0.3.2
v 2.v timeout 0.0ms 3.3MB 4983ms 7ms v/clang+gc 0.3.2

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
v 1.v 959ms 2.4ms 2.9MB 947ms 0ms v/clang+gc 0.3.2
java 1.java 1341ms 31ms 311.6MB 1660ms 80ms graal/jvm 17.0.6
java 1.java 1424ms 19ms 274.6MB 1790ms 63ms openjdk 19
v 1.v 1425ms 42ms 2.9MB 1410ms 0ms v/clang 0.3.2
java 1.java 1452ms 11ms 294.2MB 1840ms 70ms openjdk 20
v 2.v 1737ms 35ms 2.7MB 1723ms 0ms v/clang+gc 0.3.2
java 1.java 1943ms 14ms 917.6MB 1850ms 570ms openjdk/zgc 19

spectral-norm

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
java 2-m.java 4207ms 116ms 89.8MB 8140ms 20ms graal/jvm 17.0.6
java 2.java timeout 0.0ms 46.0MB 9730ms 17ms openjdk 19
java 2.java timeout 0.0ms 40.7MB 9717ms 13ms openjdk 20
java 2.java timeout 0.0ms 41.8MB 9627ms 43ms openjdk/zgc 19
v 1.v timeout 0.0ms 3.0MB 4983ms 0ms v/clang 0.3.2
v 1.v timeout 0.0ms 3.1MB 4987ms 0ms v/clang+gc 0.3.2

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
java 2-m.java 1208ms 43ms 91.2MB 2237ms 27ms graal/jvm 17.0.6
v 1.v 1551ms 0.4ms 2.8MB 1537ms 0ms v/clang 0.3.2
v 1.v 1556ms 5.3ms 2.8MB 1543ms 0ms v/clang+gc 0.3.2
java 2-m.java 1621ms 30ms 44.3MB 3063ms 17ms openjdk 19
java 2-m.java 1721ms 70ms 40.9MB 3273ms 10ms openjdk 20
java 2-m.java 1769ms 188ms 42.1MB 3277ms 53ms openjdk/zgc 19

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
v 1.v 393ms 0.4ms 2.6MB 380ms 0ms v/clang+gc 0.3.2
v 1.v 400ms 9.6ms 2.5MB 380ms 0ms v/clang 0.3.2
java 2-m.java 435ms 21ms 89.1MB 727ms 33ms graal/jvm 17.0.6
java 2-m.java 552ms 40ms 41.0MB 977ms 13ms openjdk 20
java 2-m.java 589ms 38ms 44.3MB 1043ms 10ms openjdk 19
java 2-m.java 636ms 31ms 43.9MB 1040ms 57ms openjdk/zgc 19