/mobile Handheld Friendly website
Ubuntu : Intel® Q6600® one core |
Each table row shows performance measurements for this OCaml program with a particular command-line input value N.
| N | CPU secs | Elapsed secs | Memory KB | Code B | ≈ CPU Load |
|---|---|---|---|---|---|
| 10 | 0.44 | 0.44 | 580 | 473 | 4% 2% 0% 100% |
| 11 | 5.44 | 5.44 | 580 | 473 | 0% 1% 0% 100% |
| 12 | 73.46 | 73.47 | 580 | 473 | 0% 0% 0% 100% |
Read the ↓ make, command line, and program output logs to see how this program was run.
Read fannkuch-redux benchmark to see what this program should do.
The OCaml native-code compiler, version 4.00.1
(* The Computer Language Benchmarks Game http://benchmarksgame.alioth.debian.org/ contributed by Ethan Burns *) (** Flip the front [n] pancakes of [a]. *) let flip n (a : int array) = for i = 0 to n / 2 do let t = a.(i) in let k = n - i in a.(i) <- a.(k); a.(k) <- t; done (** Count the number of flips so that pancake 0 is at index 0. *) let rec count c ary = let z = ary.(0) in if z <> 0 then begin flip z ary; count (c + 1) ary end else c (** Rotate the first [n] pancakes of [a]. *) let rotate n (a : int array) = let t = a.(0) in let m = n - 1 in for i = 1 to m do a.(i - 1) <- a.(i); done; a.(m) <- t (** Call [f] on each permutation of [n] numbers in order. *) let iter_perms n f = let rec do_iter num perm copy f ht = if ht = 1 then begin for i = 0 to n - 1 do copy.(i) <- perm.(i) done; f !num copy; incr num; end else for i = 1 to ht do do_iter num perm copy f (ht - 1); rotate ht perm; done in let perm = Array.init n (fun i -> i) in let copy = Array.create n 0 in let num = ref 0 in do_iter num perm copy f n let _ = let n = int_of_string Sys.argv.(1) in let csum = ref 0 and m = ref 0 in iter_perms n (fun num a -> let c = count 0 a in (* csum update from Otto Bommer's Scala ver. *) csum := !csum + c * (1 - (num land 1) lsl 1); if c > !m then m := c;); Printf.printf "%d\nPfannkuchen(%d) = %d\n" !csum n !m
Sun, 03 Feb 2013 02:04:41 GMT MAKE: mv fannkuchredux.ocaml-2.ocaml fannkuchredux.ocaml-2.ml /usr/local/bin/ocamlopt -noassert -unsafe -nodynlink -inline 100 unix.cmxa fannkuchredux.ocaml-2.ml -o fannkuchredux.ocaml-2.ocaml_run File "fannkuchredux.ocaml-2.ml", line 1: Warning 24: bad source file name: "Fannkuchredux.ocaml-2" is not a valid module name. rm fannkuchredux.ocaml-2.ml 0.23s to complete and log all make actions COMMAND LINE: ./fannkuchredux.ocaml-2.ocaml_run 12 PROGRAM OUTPUT: 3968050 Pfannkuchen(12) = 65