The Computer Language
Benchmarks Game

OCaml versus C++ g++ fastest programs

Always look at the source code.

These are only the fastest programs. Look at the other programs. They may seem more-like a fair comparison to you.

pidigits
source secs mem gz busy cpu load
OCaml 0.74 6,144 593 0.78 0% 0% 100% 4%
C++ g++ 0.71 4,184 513 0.71 0% 100% 0% 0%
fannkuch-redux
source secs mem gz busy cpu load
OCaml 8.52 19,072 1004 34.08 100% 100% 100% 100%
C++ g++ 8.07 1,848 980 31.38 93% 98% 100% 98%
n-body
source secs mem gz busy cpu load
OCaml 6.72 1,464 1251 6.76 0% 100% 0% 1%
C++ g++ 4.09 1,748 1808 4.12 0% 100% 1% 0%
reverse-complement
source secs mem gz busy cpu load
OCaml 1.66 34,044 1368 4.25 61% 65% 61% 69%
C++ g++ 0.63 499,624 2093 0.64 0% 0% 100% 2%
fasta
source secs mem gz busy cpu load
OCaml 3.27 203,380 1189 3.31 1% 0% 0% 100%
C++ g++ 1.04 4,464 2344 3.87 92% 93% 93% 93%
binary-trees
source secs mem gz busy cpu load
OCaml 4.04 152,736 751 11.19 39% 77% 68% 93%
C++ g++ 1.12 200,184 890 4.05 88% 88% 88% 99%
spectral-norm
source secs mem gz busy cpu load
OCaml 5.36 3,436 377 5.37 0% 0% 100% 0%
C++ g++ 0.72 2,360 1044 2.85 99% 100% 99% 100%
k-nucleotide
source secs mem gz busy cpu load
OCaml 14.87 255,560 1833 40.68 48% 50% 86% 90%
C++ g++ 1.93 156,432 1631 5.93 69% 70% 70% 98%
mandelbrot
source secs mem gz busy cpu load
OCaml 7.56 4,620 717 30.12 100% 100% 99% 100%
C++ g++ 0.84 34,608 3542 3.27 98% 98% 96% 99%
regex-redux
source secs mem gz busy cpu load
OCaml 14.84 901,904 637 15.29 100% 0% 1% 1%
C++ g++ 1.08 203,848 1315 3.40 100% 64% 73% 78%
OCaml

The OCaml native-code compiler, version 4.11.0

C++ g++

g++ (Ubuntu 10.2.0-13ubuntu1) 10.2.0