Team PLClub ICFP entry -- comparing the performance of OCAML and SML

Stephen Weeks sweeks@intertrust.com
Fri, 13 Oct 2000 14:13:25 -0700 (PDT)


> I'm dropping off comp.lang.ml, since this is getting pretty narrow in
> its interest.

Makes sense.  Perhaps we should move this over to
sml-implementers@lists.sourceforge.net, since other SML implementers might be
interested.

> The chess input is probably the best test case to judge overall performance,
> since it stresses most of the GML specification.  Fractal, on the other
> hand, is a Tier-1 test that has a single plane and lots of spheres, so
> it stresses the sphere intersection code (and not much else).  

As to the "best test case", from a raytracing perspective I agree.  From a
compiler writer's perspective I disagree.  Different scenes stress different
parts of the SML code and hence different parts of the compiler.  I don't see
any reason to prefer one scene to another.

> Thus the sqrt bottleneck could be very important.
> In the actual application,
> there may be I-cache effects that make the SML version of sin slower;

Did you mean sqrt, not sin?

> also the range of inputs might require more computation.  

I agree, but I would be surprised to see it change the 4.9 second estimate of
sqrt time by a factor of more than 5, which is what it would have to do to
explain the difference on fractal between SML/NJ and OCAML or MLton.

> How did you
> determine your calls per second number?

I created the following program, z.sml, and ran the following Makefile.  The
user + sys time on my machine was roughly 22 seconds, which translates to
roughly 460,000 sqrts per second.

--------------------------------------------------------------------------------
(* z.sml *)
val _ = SMLofNJ.Internals.GC.messages false
fun loop (i, x) =
   if i = 0
      then x
   else loop(i - 1, Real.Math.sqrt(1.0 - x))
val _ =
   SMLofNJ.exportFn
   ("z", fn _ => (loop(10000000, 0.5); 0))
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
# Makefile
sml = $$HOME/src/ml/sml-nj/110.29/bin/sml

all: test

.PHONY: test
test:
	$(sml) <z.sml
	time $(sml) @SMLload=z.x86-linux
	rm -f z.86-linux
--------------------------------------------------------------------------------