The Computer Language
Benchmarks Game

OCaml programs versus Java

by benchmark task performance

reverse-complement
source secs mem gz cpu cpu load
OCaml 0.75 ? 1314 ? 46% 53% 61% 52%
Java 1.13 199,672 2124 2.76 48% 74% 70% 54%
n-body
source secs mem gz cpu cpu load
OCaml 21.67 1,276 1239 21.66 1% 100% 0% 1%
Java 22.56 35,208 1424 22.65 99% 1% 1% 1%
spectral-norm
source secs mem gz cpu cpu load
OCaml 4.36 5,072 907 15.48 92% 91% 93% 91%
Java 4.25 36,364 950 16.30 97% 96% 95% 97%
fannkuch-redux
source secs mem gz cpu cpu load
OCaml 16.23 ? 1017 ? 100% 100% 100% 100%
Java 15.09 34,764 1282 59.26 99% 98% 98% 100%
binary-trees
source secs mem gz cpu cpu load
OCaml 9.82 115,804 746 28.90 90% 96% 39% 72%
Java 8.58 966,808 835 28.98 86% 84% 90% 81%
mandelbrot
source secs mem gz cpu cpu load
OCaml 13.78 8,300 710 54.76 100% 100% 100% 100%
Java 6.08 77,056 796 23.61 97% 97% 99% 97%
k-nucleotide
source secs mem gz cpu cpu load
OCaml 19.69 259,992 1789 54.82 71% 90% 50% 70%
Java 8.38 375,988 1802 26.25 73% 97% 70% 74%
regex-redux
source secs mem gz cpu cpu load
OCaml 24.92 968,548 622 24.89 1% 1% 1% 100%
Java 10.38 634,548 929 29.48 70% 64% 69% 82%
fasta
source secs mem gz cpu cpu load
OCaml 5.89 201,740 1161 5.88 100% 1% 0% 2%
Java 2.32 46,816 2457 6.37 61% 60% 96% 60%
pidigits
source secs mem gz cpu cpu load
OCaml   Make Error
Java 0.30 856 938 0.37 45% 7% 17% 71%
OCaml

The OCaml native-code compiler, version 4.05.0

Java

java 9
Java(TM) SE Runtime Environment (build 9+181)
Java HotSpot(TM) 64-Bit Server VM (build 9+181, mixed mode)