The Computer Language
22.01 Benchmarks Game

OCaml versus C++ g++ fastest programs

Always look at the source code. These are only the fastest programs.

If they are manually vectorized SIMD, does the host language matter? You might not be interested in the most optimised programs.

Look at "mandelbrot" or "spectral-norm" or other measurement tables. Look at the other programs. Choose which programs you want to compare.

pidigits
source secs mem gz busy cpu load
OCaml 0.74 6,188 593 0.75 0% 0% 1% 100%
C++ g++ 0.59 5,024 986 2.36 98% 100% 100% 100%
regex-redux
source secs mem gz busy cpu load
OCaml 2.46 526,736 647 4.22 0% 0% 100% 71%
C++ g++ 1.11 203,844 1315 3.43 76% 63% 100% 71%
reverse-complement
source secs mem gz busy cpu load
OCaml 1.65 34,404 1368 4.44 68% 68% 62% 72%
C++ g++ 0.64 499,692 2093 0.64 0% 0% 0% 100%
fannkuch-redux
source secs mem gz busy cpu load
OCaml 8.92 13,028 1017 35.63 100% 100% 100% 100%
C++ g++ 3.26 1,992 1528 12.94 98% 100% 100% 100%
n-body
source secs mem gz busy cpu load
OCaml 6.83 1,704 1251 7.00 1% 100% 0% 1%
C++ g++ 2.17 992 1927 2.23 1% 0% 100% 1%
fasta
source secs mem gz busy cpu load
OCaml 3.34 203,504 1189 3.42 2% 0% 100% 0%
C++ g++ 0.77 2,676 2751 1.59 99% 38% 66% 4%
binary-trees
source secs mem gz busy cpu load
OCaml 4.22 135,328 751 11.52 52% 40% 83% 99%
C++ g++ 0.94 176,440 890 3.33 85% 87% 83% 100%
spectral-norm
source secs mem gz busy cpu load
OCaml 5.32 3,976 377 5.34 0% 100% 0% 0%
C++ g++ 0.72 1,296 1044 2.86 99% 100% 100% 99%
k-nucleotide
source secs mem gz busy cpu load
OCaml 15.55 255,564 1833 41.30 96% 39% 36% 95%
C++ g++ 1.96 156,492 1631 5.97 69% 98% 68% 69%
mandelbrot
source secs mem gz busy cpu load
OCaml 7.53 4,716 717 30.05 100% 100% 100% 100%
C++ g++ 0.84 34,800 3542 3.28 98% 99% 98% 98%
OCaml

The OCaml native-code compiler, version 4.13.1

C++ g++

g++ (Ubuntu 11.2.0-7ubuntu2) 11.2.0