The Computer Language
Benchmarks Game

OCaml programs versus Java

by benchmark task performance

reverse-complement
source secs mem gz cpu cpu load
OCaml 0.76 ? 1314 ? 46% 58% 57% 49%
Java 1.10 345,352 1661 2.40 33% 82% 53% 54%
binary-trees
source secs mem gz cpu cpu load
OCaml 9.95 115,760 746 29.67 99% 73% 41% 87%
Java 11.26 593,156 835 39.02 85% 88% 90% 88%
n-body
source secs mem gz cpu cpu load
OCaml 21.68 1,252 1239 21.67 0% 0% 100% 1%
Java 21.54 27,092 1489 21.56 1% 1% 100% 1%
spectral-norm
source secs mem gz cpu cpu load
OCaml 4.35 5,008 907 15.54 90% 93% 93% 93%
Java 4.29 29,884 950 16.56 96% 97% 99% 95%
fannkuch-redux
source secs mem gz cpu cpu load
OCaml 16.52 ? 1004 ? 100% 100% 100% 100%
Java 13.74 30,368 1282 54.12 100% 98% 98% 99%
mandelbrot
source secs mem gz cpu cpu load
OCaml 13.76 8,240 710 54.76 100% 100% 100% 100%
Java 7.10 90,588 796 27.92 99% 99% 98% 98%
regex-redux
source secs mem gz cpu cpu load
OCaml 25.09 968,516 622 25.06 1% 54% 0% 46%
Java 12.31 902,528 929 38.75 73% 76% 86% 81%
k-nucleotide
source secs mem gz cpu cpu load
OCaml 20.02 261,944 1789 56.21 48% 91% 95% 48%
Java 7.93 465,372 1802 25.11 75% 75% 75% 93%
fasta
source secs mem gz cpu cpu load
OCaml 5.88 200,032 1161 5.88 3% 100% 1% 1%
Java 2.13 36,036 2457 5.66 94% 58% 59% 60%
pidigits
source secs mem gz cpu cpu load
OCaml   Make Error
Java 0.23 784 938 0.24 48% 57% 9% 9%
OCaml

The OCaml native-code compiler, version 4.04.0

Java

java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)