Crystal VS Zig benchmarks

Current benchmark data was generated on Wed Feb 08 2023, full log can be found HERE

CONTRIBUTIONS are WELCOME!

[x86_64][2 cores] Intel(R) Xeon(R) Platinum 8171M 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
crystal 1.cr 2438ms 1.7ms 64.3MB 2393ms 23ms crystal 1.7.2
zig 1.zig 2850ms 12ms 49.1MB 2820ms 13ms zig 0.11.0-dev.1580+a5b34a61a

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
crystal 1.cr 185ms 11ms 11.0MB 167ms 0ms crystal 1.7.2
zig 1.zig 237ms 2.6ms 7.0MB 220ms 0ms zig 0.11.0-dev.1580+a5b34a61a

coro-prime-sieve

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
crystal 1.cr 2418ms 41ms 20.3MB 2357ms 37ms crystal 1.7.2

Input: 1000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
crystal 1.cr 136ms 1.4ms 7.2MB 120ms 3ms crystal 1.7.2

edigits

Input: 250001

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
crystal 1.cr 95ms 7.6ms 6.4MB 80ms 3ms crystal 1.7.2
zig 1.zig timeout 0.0ms 2.6MB 4983ms 0ms zig 0.11.0-dev.1580+a5b34a61a

Input: 100000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
crystal 1.cr 32ms 0.7ms 5.3MB 20ms 0ms crystal 1.7.2
zig 1.zig 975ms 29ms 2.0MB 950ms 7ms zig 0.11.0-dev.1580+a5b34a61a

fannkuch-redux

Input: 11

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 2-m.zig 1401ms 16ms 1.1MB 2713ms 0ms zig 0.11.0-dev.1580+a5b34a61a
zig 3-i.zig 1699ms 3.5ms 1.0MB 1687ms 0ms zig 0.11.0-dev.1580+a5b34a61a
zig 2.zig 2854ms 1.2ms 1.0MB 2843ms 0ms zig 0.11.0-dev.1580+a5b34a61a
zig 1.zig 3856ms 30ms 1.0MB 3847ms 0ms zig 0.11.0-dev.1580+a5b34a61a
crystal 1.cr 4460ms 4.4ms 3.0MB 4447ms 0ms crystal 1.7.2

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 2-m.zig 134ms 1.0ms 1.1MB 233ms 0ms zig 0.11.0-dev.1580+a5b34a61a
zig 3-i.zig 145ms 0.7ms 1.0MB 130ms 0ms zig 0.11.0-dev.1580+a5b34a61a
zig 2.zig 242ms 0.2ms 1.0MB 230ms 0ms zig 0.11.0-dev.1580+a5b34a61a
zig 1.zig 323ms 0.7ms 1.0MB 310ms 0ms zig 0.11.0-dev.1580+a5b34a61a
crystal 1.cr 372ms 15ms 3.0MB 360ms 0ms crystal 1.7.2

fasta

Input: 2500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 1.zig 165ms 2.4ms 1.0MB 153ms 0ms zig 0.11.0-dev.1580+a5b34a61a
crystal 2.cr 873ms 17ms 3.1MB 757ms 100ms crystal 1.7.2
crystal 1.cr 1124ms 3.1ms 14.6MB 967ms 137ms crystal 1.7.2

Input: 250000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 1.zig 22ms 1.6ms 1.0MB 10ms 0ms zig 0.11.0-dev.1580+a5b34a61a
crystal 2.cr 91ms 0.9ms 3.2MB 73ms 7ms crystal 1.7.2
crystal 1.cr 117ms 0.6ms 4.5MB 90ms 17ms crystal 1.7.2

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 1.zig 2.1ms 0.7ms 0.9MB 0ms 0ms zig 0.11.0-dev.1580+a5b34a61a
crystal 1.cr 2.6ms 0.5ms 3.0MB 0ms 0ms crystal 1.7.2

http-server

Input: 3000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
crystal 1.cr 3606ms 81ms 193.5MB 693ms 417ms crystal 1.7.2

Input: 500

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
crystal 1.cr 1299ms 5.5ms 43.4MB 73ms 63ms crystal 1.7.2

lru

Input: 1000 1000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 1.zig 59ms 1.7ms 2.8MB 50ms 0ms zig 0.11.0-dev.1580+a5b34a61a
crystal 0-unsafe.cr 69ms 3.1ms 3.0MB 57ms 0ms crystal 1.7.2
crystal 1.cr 113ms 1.8ms 3.0MB 100ms 0ms crystal 1.7.2

Input: 1000 3000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 1.zig 164ms 1.5ms 2.9MB 150ms 0ms zig 0.11.0-dev.1580+a5b34a61a
crystal 0-unsafe.cr 195ms 4.7ms 3.0MB 180ms 0ms crystal 1.7.2
crystal 1.cr 324ms 1.4ms 3.0MB 310ms 0ms crystal 1.7.2

Input: 100 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 1.zig 33ms 8.3ms 1.3MB 23ms 0ms zig 0.11.0-dev.1580+a5b34a61a
crystal 0-unsafe.cr 36ms 2.2ms 2.9MB 23ms 0ms crystal 1.7.2
crystal 1.cr 56ms 0.1ms 2.9MB 47ms 0ms crystal 1.7.2

mandelbrot

Input: 5000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 1.zig 457ms 14ms 4.2MB 443ms 0ms zig 0.11.0-dev.1580+a5b34a61a
crystal 1.cr 492ms 4.7ms 9.8MB 480ms 0ms crystal 1.7.2

Input: 1000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 1.zig 23ms 1.3ms 1.0MB 10ms 0ms zig 0.11.0-dev.1580+a5b34a61a
crystal 1.cr 26ms 0.0ms 6.7MB 13ms 0ms crystal 1.7.2

merkletrees

Input: 17

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 1.zig 1335ms 3.4ms 41.1MB 1300ms 13ms zig 0.11.0-dev.1580+a5b34a61a
crystal 1.cr 1790ms 9.6ms 64.3MB 1750ms 17ms crystal 1.7.2

Input: 15

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 1.zig 269ms 1.4ms 11.0MB 253ms 0ms zig 0.11.0-dev.1580+a5b34a61a
crystal 1.cr 320ms 17ms 22.1MB 300ms 7ms crystal 1.7.2

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 2.zig 308ms 5.8ms 1.1MB 293ms 0ms zig 0.11.0-dev.1580+a5b34a61a
zig 1.zig 462ms 6.7ms 1.0MB 453ms 0ms zig 0.11.0-dev.1580+a5b34a61a
crystal 1.cr 670ms 3.5ms 2.9MB 657ms 0ms crystal 1.7.2
crystal 2.cr 694ms 9.6ms 3.0MB 683ms 0ms crystal 1.7.2

Input: 500000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 2.zig 35ms 0.6ms 1.0MB 27ms 0ms zig 0.11.0-dev.1580+a5b34a61a
zig 1.zig 50ms 1.5ms 1.0MB 40ms 0ms zig 0.11.0-dev.1580+a5b34a61a
crystal 1.cr 73ms 1.3ms 3.0MB 60ms 0ms crystal 1.7.2
crystal 2.cr 79ms 4.1ms 2.9MB 70ms 0ms crystal 1.7.2

nsieve

Input: 12

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 2.zig 439ms 0.8ms 6.0MB 423ms 0ms zig 0.11.0-dev.1580+a5b34a61a
crystal 2.cr 513ms 4.0ms 7.8MB 500ms 0ms crystal 1.7.2
zig 1.zig 943ms 42ms 40.1MB 917ms 10ms zig 0.11.0-dev.1580+a5b34a61a
crystal 1.cr 1150ms 55ms 41.9MB 1130ms 7ms crystal 1.7.2

Input: 10

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 2.zig 97ms 2.8ms 2.1MB 87ms 0ms zig 0.11.0-dev.1580+a5b34a61a
crystal 2.cr 117ms 2.4ms 4.1MB 103ms 0ms crystal 1.7.2
zig 1.zig 128ms 1.0ms 10.9MB 110ms 0ms zig 0.11.0-dev.1580+a5b34a61a
crystal 1.cr 175ms 1.0ms 12.9MB 160ms 0ms crystal 1.7.2

pidigits

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 1.zig 2406ms 1.7ms 2.3MB 2373ms 13ms zig 0.11.0-dev.1580+a5b34a61a
crystal 1.cr 3260ms 137ms 7.4MB 3223ms 20ms crystal 1.7.2

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 1.zig 558ms 10ms 1.8MB 547ms 0ms zig 0.11.0-dev.1580+a5b34a61a
crystal 1.cr 703ms 27ms 5.8MB 677ms 10ms crystal 1.7.2

regex-redux

Input: 2500000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
crystal 1.cr 2759ms 1.3ms 174.0MB 2687ms 57ms crystal 1.7.2

Input: 250000_in

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
crystal 1.cr 287ms 1.0ms 32.1MB 260ms 10ms crystal 1.7.2

spectral-norm

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 2-m.zig 1088ms 3.9ms 1.2MB 2083ms 0ms zig 0.11.0-dev.1580+a5b34a61a
zig 2.zig 2072ms 6.8ms 1.0MB 2063ms 0ms zig 0.11.0-dev.1580+a5b34a61a
zig 1.zig 4631ms 11ms 1.0MB 4617ms 0ms zig 0.11.0-dev.1580+a5b34a61a
crystal 1.cr timeout 0.0ms 4.0MB 4977ms 3ms crystal 1.7.2

Input: 4000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 2-m.zig 284ms 2.0ms 1.2MB 510ms 0ms zig 0.11.0-dev.1580+a5b34a61a
zig 2.zig 525ms 10ms 1.0MB 513ms 0ms zig 0.11.0-dev.1580+a5b34a61a
zig 1.zig 1156ms 3.2ms 1.0MB 1143ms 0ms zig 0.11.0-dev.1580+a5b34a61a
crystal 1.cr 1847ms 33ms 3.7MB 1837ms 0ms crystal 1.7.2

Input: 2000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
zig 2-m.zig 79ms 1.5ms 1.1MB 127ms 0ms zig 0.11.0-dev.1580+a5b34a61a
zig 2.zig 136ms 2.1ms 1.6MB 127ms 0ms zig 0.11.0-dev.1580+a5b34a61a
zig 1.zig 294ms 0.5ms 1.0MB 280ms 0ms zig 0.11.0-dev.1580+a5b34a61a
crystal 1.cr 466ms 4.6ms 3.6MB 453ms 0ms crystal 1.7.2