The Computer Language
Benchmarks Game

OCaml programs versus Java

by benchmark task performance

reverse-complement
source secs mem gz cpu cpu load
OCaml 0.74 ? 1314 ? 63% 61% 42% 57%
Java 1.11 345,308 1661 2.44 33% 58% 54% 80%
fannkuch-redux
source secs mem gz cpu cpu load
OCaml 16.14 ? 1017 ? 100% 100% 100% 100%
Java 17.74 30,048 1282 69.90 98% 98% 100% 99%
n-body
source secs mem gz cpu cpu load
OCaml 21.69 1,084 1239 21.68 1% 1% 100% 1%
Java 21.50 27,240 1489 21.52 1% 1% 100% 0%
spectral-norm
source secs mem gz cpu cpu load
OCaml 4.46 4,792 907 15.50 90% 93% 88% 90%
Java 4.29 31,428 950 16.56 97% 96% 98% 97%
binary-trees
source secs mem gz cpu cpu load
OCaml 23.42 173,568 784 70.56 84% 90% 77% 55%
Java 11.52 643,924 889 40.54 89% 92% 85% 89%
mandelbrot
source secs mem gz cpu cpu load
OCaml 13.78 7,800 710 54.76 100% 100% 100% 99%
Java 5.89 89,504 796 23.08 98% 98% 98% 99%
k-nucleotide
source secs mem gz cpu cpu load
OCaml 19.76 256,940 1789 54.18 43% 96% 43% 94%
Java 8.02 467,004 1802 25.57 76% 98% 73% 74%
fasta
source secs mem gz cpu cpu load
OCaml 5.79 202,460 1161 5.79 1% 2% 100% 1%
Java 2.14 36,192 2457 5.68 71% 58% 62% 77%
regex-redux
source secs mem gz cpu cpu load
OCaml   Bad Output
Java 0.69 46,096 929 1.58 85% 67% 53% 53%
pidigits
source secs mem gz cpu cpu load
OCaml   Make Error
Java 0.24 828 938 0.24 71% 38% 8% 4%
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)