C++ VS Crystal 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.)

fannkuch-redux

Input: 11

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
cpp 1-im.cpp 794ms 8.7ms 3.9MB 1543ms 0ms clang++ 14.0.0
cpp 1-im.cpp 823ms 2.4ms 1.4MB 1570ms 0ms g++ 12.2.0
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
cpp 1-im.cpp 75ms 1.9ms 4.0MB 127ms 0ms clang++ 14.0.0
cpp 1-im.cpp 79ms 2.5ms 1.4MB 130ms 0ms g++ 12.2.0
crystal 1.cr 372ms 15ms 3.0MB 360ms 0ms crystal 1.7.2

helloworld

Input: QwQ

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
cpp 1.cpp 2.4ms 0.7ms 1.3MB 0ms 0ms g++ 12.2.0
cpp 1.cpp 2.4ms 0.7ms 1.4MB 0ms 0ms clang++ 14.0.0
crystal 1.cr 2.6ms 0.5ms 3.0MB 0ms 0ms crystal 1.7.2

nbody

Input: 5000000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
cpp 0-i.cpp 218ms 1.5ms 1.4MB 203ms 0ms g++ 12.2.0
cpp 0-i.cpp 253ms 4.3ms 1.4MB 243ms 0ms clang++ 14.0.0
cpp 1.cpp 413ms 9.0ms 1.4MB 400ms 0ms g++ 12.2.0
cpp 1.cpp 417ms 9.1ms 1.5MB 407ms 0ms clang++ 14.0.0
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
cpp 0-i.cpp 25ms 0.3ms 1.3MB 13ms 0ms g++ 12.2.0
cpp 0-i.cpp 28ms 0.2ms 1.4MB 20ms 0ms clang++ 14.0.0
cpp 1.cpp 45ms 0.3ms 1.4MB 40ms 0ms clang++ 14.0.0
cpp 1.cpp 46ms 1.9ms 1.3MB 40ms 0ms g++ 12.2.0
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
crystal 2.cr 513ms 4.0ms 7.8MB 500ms 0ms crystal 1.7.2
cpp 1.cpp 769ms 8.0ms 7.4MB 750ms 0ms clang++ 14.0.0
cpp 1.cpp 769ms 17ms 7.7MB 753ms 0ms g++ 12.2.0
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
crystal 2.cr 117ms 2.4ms 4.1MB 103ms 0ms crystal 1.7.2
crystal 1.cr 175ms 1.0ms 12.9MB 160ms 0ms crystal 1.7.2
cpp 1.cpp 177ms 1.4ms 4.0MB 167ms 0ms g++ 12.2.0
cpp 1.cpp 185ms 4.4ms 3.9MB 173ms 0ms clang++ 14.0.0

spectral-norm

Input: 8000

lang code time stddev peak-mem mem time(user) time(sys) compiler compiler/runtime
cpp 8-m.cpp 1061ms 4.5ms 3.7MB 2067ms 3ms clang++ 14.0.0
cpp 7-m.cpp 1065ms 5.3ms 3.3MB 2080ms 0ms clang++ 14.0.0
cpp 8-m.cpp 1071ms 5.9ms 1.3MB 2087ms 0ms g++ 12.2.0
cpp 7-m.cpp 1071ms 11ms 1.4MB 2073ms 0ms g++ 12.2.0
cpp 6-im.cpp 2187ms 29ms 1.3MB 4277ms 0ms g++ 12.2.0
cpp 6-im.cpp 2209ms 24ms 3.4MB 4327ms 3ms clang++ 14.0.0
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
cpp 7-m.cpp 271ms 2.1ms 1.3MB 510ms 0ms g++ 12.2.0
cpp 7-m.cpp 278ms 3.3ms 3.3MB 517ms 0ms clang++ 14.0.0
cpp 8-m.cpp 281ms 2.7ms 1.3MB 523ms 0ms g++ 12.2.0
cpp 8-m.cpp 283ms 8.5ms 3.5MB 527ms 0ms clang++ 14.0.0
cpp 6-im.cpp 546ms 13ms 1.3MB 1053ms 0ms g++ 12.2.0
cpp 6-im.cpp 560ms 0.6ms 3.3MB 1077ms 3ms clang++ 14.0.0
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
cpp 7-m.cpp 73ms 1.9ms 1.4MB 120ms 0ms g++ 12.2.0
cpp 8-m.cpp 77ms 0.2ms 3.3MB 130ms 0ms clang++ 14.0.0
cpp 8-m.cpp 78ms 1.5ms 1.3MB 130ms 0ms g++ 12.2.0
cpp 7-m.cpp 79ms 2.5ms 3.5MB 130ms 0ms clang++ 14.0.0
cpp 6-im.cpp 151ms 0.9ms 1.3MB 273ms 0ms g++ 12.2.0
cpp 6-im.cpp 152ms 0.4ms 3.7MB 273ms 0ms clang++ 14.0.0
crystal 1.cr 466ms 4.6ms 3.6MB 453ms 0ms crystal 1.7.2