The Computer Language
Benchmarks Game

OCaml versus C++ g++ fastest programs

Always look at the source code.

These are only the fastest programs. Do some of them use manually vectorized SIMD? 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.89 5,968 593 0.90 0% 0% 1% 100%
C++ g++ 0.66 5,152 986 2.63 100% 100% 100% 100%
regex-redux
source secs mem gz busy cpu load
OCaml 2.37 510,132 647 4.12 72% 1% 100% 1%
C++ g++ 1.10 203,924 1315 3.43 63% 77% 71% 100%
fannkuch-redux
source secs mem gz busy cpu load
OCaml 8.66 18,900 1004 34.60 100% 100% 100% 100%
C++ g++ 3.29 1,892 1528 13.06 100% 100% 100% 97%
n-body
source secs mem gz busy cpu load
OCaml 6.70 1,468 1251 6.70 100% 0% 0% 0%
C++ g++ 2.12 764 1927 2.17 0% 2% 100% 0%
reverse-complement
source secs mem gz busy cpu load
OCaml 1.68 34,024 1368 4.31 56% 57% 75% 69%
C++ g++ 0.52 1,788 1853 0.52 0% 98% 0% 2%
fasta
source secs mem gz busy cpu load
OCaml 3.28 203,300 1189 3.29 0% 0% 100% 0%
C++ g++ 0.77 2,504 2751 1.52 64% 0% 99% 37%
binary-trees
source secs mem gz busy cpu load
OCaml 4.68 152,716 751 13.23 78% 99% 42% 64%
C++ g++ 0.94 176,428 1122 3.39 86% 88% 100% 85%
spectral-norm
source secs mem gz busy cpu load
OCaml 5.36 3,448 377 5.36 0% 0% 0% 100%
C++ g++ 0.72 1,192 1044 2.85 99% 99% 100% 100%
k-nucleotide
source secs mem gz busy cpu load
OCaml 15.09 255,396 1833 40.72 38% 94% 64% 74%
C++ g++ 1.93 156,548 1631 5.88 69% 93% 69% 75%
mandelbrot
source secs mem gz busy cpu load
OCaml 7.53 4,480 717 30.02 100% 100% 100% 100%
C++ g++ 0.84 34,780 3542 3.27 99% 98% 98% 96%
OCaml

The OCaml native-code compiler, version 4.12.0

C++ g++

g++ (Ubuntu 10.3.0-1ubuntu1) 10.3.0