Ray tracer Benchmark

Source code

OptimisationC++Java
(by Alex Jonas)
OCamlSML
(for MLton)
Stalin
(by Jeff Siskind)
Lisp
(by Juho Snellman)
Haskell
(by Lennart Augustsson)
Minimal ray.cpp ray.java ray.ml ray.sml ray.sc ray.lisp ray.hs
Tighter bounding
volumes
ray.cpp ray.java ray.ml ray.sml ray.sc ray.lisp ray.hs
Partially specialised
shadow intersection
ray.cpp ray.java ray.ml ray.sml ray.sc ray.lisp ray.hs
Fully specialised
shadow intersection
ray.cpp ray.java ray.ml ray.sml ray.sc ray.lisp ray.hs
Low-level optimizations ray.cpp ray.java ray.ml ray.sml ray.lisp ray.hs

Compile commands

The following compiler versions and command-line arguments were used to generate the executables or heap images (32-bit then 64-bit):

  • C++: g++ 4.2.3:
    g++ -O3 -ffast-math ray.cpp -o ray
    g++ -O3 -ffast-math ray.cpp -o ray
    
  • Java: Sun's JDK 1.6:
    javac ray.java
    javac ray.java
    
  • OCaml: ocamlopt 3.10.0:
    ocamlopt -rectypes -inline 100 -ffast-math ray.ml -o ray
    ocamlopt -rectypes -inline 100 ray.ml -o ray
    
  • SML: MLton Debian package 20070826-1:
    mlton ray.sml
    mlton -align 8 ray.sml
    
  • SML: SML/NJ 110.65:
    sml ray.sml
    
  • Lisp: SBCL 1.0.11:
    sbcl --eval '(compile-file "ray.lisp")' --eval '(quit)'
    sbcl --eval '(compile-file "ray.lisp")' --eval '(quit)'
    
  • Scheme: Stalin 0.11-4:
    stalin -Ob -Om -On -Or -Ot -dP -dC -dh -q -d -db -architecture
    IA32-align-double -no-clone-size-limit -split-even-if-no-widening -copt -O3
    -copt -fomit-frame-pointer -copt -freg-struct-return -copt -malign-double -copt
    -ffast-math ray
    stalin -Ob -Om -On -Or -Ot -dP -dC -dh -q -d -db -no-clone-size-limit
    -split-even-if-no-widening -copt -O3 -copt -fomit-frame-pointer -copt
    -freg-struct-return -copt -ffast-math ray
    
  • Glasgow Haskell Compiler 6.8.1:
    rm -f ray ray.hi ray.o; ghc-6.8.1 -O3 -fvia-C -funbox-strict-fields -optc-O3
    -fexcess-precision -optc-ffast-math -funfolding-keeness-factor=10 ray.hs -o ray
    

Run commands

The following commands were used to run the programs:

  • C++:
    ./ray 9 512
    
  • Java:
    java -server ray 9 512
    
  • OCaml:
    ./ray 9 512
    
  • SML:
    ./ray 9 512
    
  • SML:
    sml @SMLload=ray 9 512
    
  • Lisp:
    sbcl --noinform --eval '(load "ray.fasl")' --eval '(main 9 "image.pgm" 512)' --eval '(quit)'
    
  • Scheme:
    ./ray 9 512
    
  • Haskell:
    ./ray
    

Output

All of the programs generate the same ray traced image, containing


Figure: Ray traced scene.

Previous: Ray tracer language comparison Next: Results