performance measurements

Each table row shows performance measurements for this SML MLton program with a particular command-line input value N.

 N  CPU secs Elapsed secs Memory KB Code B ≈ CPU Load
120.142,904530  
140.709,132530  
163.2045,760530  

Read the ↓ make, command line, and program output logs to see how this program was run.

Read binary-trees benchmark to see what this program should do.

 binary-trees SML MLton #2 program source code

(* binarytrees.mlton
 *
 * The Computer Language Shootout
 * http://shootout.alioth.debian.org/
 *
 * Contributed by Troestler Christophe
 * Ported to MLton/SML by sweeks@sweeks.com.
 * Optimized and compressed by Vesa Karvonen.
 * De-optimized by Isaac Gouy
 *)
datatype 'a tree = Nil | Node of 'a tree * 'a * 'a tree
(* fun mk 0 i = Nil | mk d i = Node (mk (d-1) (i*2-1), i, mk (d-1) (i*2)) *)
fun mk 0 i = Node (Nil, i, Nil) | mk d i = Node (mk (d-1) (i*2-1), i, mk (d-1) (i*2))
fun chk Nil = 0 | chk (Node (l, i, r)) = i + chk l - chk r
val n = valOf (Int.fromString (hd (CommandLine.arguments ()))) handle _ => 10
val min' = 4
val max' = Int.max (min' + 2, n)
val stretch' = max' + 1
val i2s = String.translate (fn #"~" => "-" | c => str c) o Int.toString
fun msg h d t = app print [h, Int.toString d, "\t check: ", i2s t, "\n"]
val () = msg "stretch tree of depth " stretch' (chk (mk stretch' 0))
val longLivedTree = mk max' 0
fun loopDepths d =
    if d > max' then ()
    else let val n = Word.toInt (Word.<< (0w1, Word.fromInt (max'-d+min')))
             fun lp (i, c) = if i=n then c
                             else lp (i+1, c + chk (mk d i) + chk (mk d (~i)))
         in msg (Int.toString (2*n)^"\t trees of depth ") d (lp (0, 0))
          ; loopDepths (d + 2) end
val () = loopDepths min'
val () = msg "long lived tree of depth " max' (chk longLivedTree)

 notes

 

 make, command-line, and program output logs

BUILD COMMANDS FOR: binarytrees.mlton-2.mlton

Fri Aug 31 16:51:22 PDT 2007

cp /home/dunham/gp4/shootout/bench/binarytrees/binarytrees.mlton-2.mlton binarytrees.mlton-2.sml
(if [ -r /home/dunham/gp4/shootout/bench/binarytrees/mlb_binarytrees.mlton-2.mlb ]; then			\
			mv /home/dunham/gp4/shootout/bench/binarytrees/mlb_binarytrees.mlton-2.mlb binarytrees.mlton-2.mlb;		\
		else							\
			echo '../../Include/mlton-src/lib.mlb binarytrees.mlton-2.sml'	\
				 >binarytrees.mlton-2.mlb;				\
		fi)
/opt/mlton-20070826/bin/mlton  -output binarytrees.mlton-2.mlton_run binarytrees.mlton-2.mlb
rm -f binarytrees.mlton-2.mlb binarytrees.mlton-2.sml

=================================================================
COMMAND LINE (%A is single numeric argument):

binarytrees.mlton-2.mlton_run %A


PROGRAM OUTPUT
==============
stretch tree of depth 17	 check: -1
131072	 trees of depth 4	 check: -131072
32768	 trees of depth 6	 check: -32768
8192	 trees of depth 8	 check: -8192
2048	 trees of depth 10	 check: -2048
512	 trees of depth 12	 check: -512
128	 trees of depth 14	 check: -128
32	 trees of depth 16	 check: -32
long lived tree of depth 16	 check: -1

Revised BSD license

  Home   Flawed   Fastest   License   Help