/mobile Handheld Friendly website

 performance measurements

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
1,0000.340.35356444  0% 0% 100% 6%
4,0005.405.401,648444  1% 0% 0% 100%
16,00085.8085.841,648444  0% 95% 5% 0%

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

Read mandelbrot benchmark to see what this program should do.

 notes

The OCaml native-code compiler, version 4.01.0

 mandelbrot OCaml #6 program source code

(*
 * The Computer Language Benchmarks Game
 * http://benchmarksgame.alioth.debian.org/
 *
 * Contributed by Paolo Ribeca
 *
 * (Very loosely based on previous version Ocaml #3,
 *  which had been contributed by
 *   Christophe TROESTLER
 *  and enhanced by
 *   Christian Szegedy and Yaron Minsky)
 *)

let niter = 50
let limit = 4.

let () =
  let w = int_of_string (Array.get Sys.argv 1) in
  let h = w in
  let fw = float w /. 2. and fh = float h /. 2. in
  Printf.printf "P4\n%i %i\n" w h;
  let red_h = h - 1 and red_w = w - 1 and byte = ref 0 in
  for y = 0 to red_h do
    let ci = float y /. fh -. 1. in
    for x = 0 to red_w do
      let cr = float x /. fw -. 1.5
      and zr = ref 0. and zi = ref 0. and trmti = ref 0. and n = ref 0 in
      begin try
	while true do
	  zi := 2. *. !zr *. !zi +. ci;
	  zr := !trmti +. cr;
	  let tr = !zr *. !zr and ti = !zi *. !zi in
	  if tr +. ti > limit then begin
	    byte := !byte lsl 1;
	    raise Exit
	  end else if incr n; !n = niter then begin
	    byte := (!byte lsl 1) lor 0x01;
	    raise Exit
	  end else
	    trmti := tr -. ti
	done
      with Exit -> ()
      end;
      if x mod 8 = 7 then output_byte stdout !byte
    done;
    let rem = w mod 8 in
    if rem != 0 then (* the row doesnt divide evenly by 8 *)
      output_byte stdout (!byte lsl (8 - rem)) (* output last few bits *)
  done

 make, command-line, and program output logs

Thu, 12 Sep 2013 18:58:43 GMT

MAKE:
mv mandelbrot.ocaml-6.ocaml mandelbrot.ocaml-6.ml
/usr/local/bin/ocamlopt -noassert -unsafe -nodynlink -inline 100 unix.cmxa mandelbrot.ocaml-6.ml -o mandelbrot.ocaml-6.ocaml_run
File "mandelbrot.ocaml-6.ml", line 1:
Warning 24: bad source file name: "Mandelbrot.ocaml-6" is not a valid module name.
rm mandelbrot.ocaml-6.ml
0.24s to complete and log all make actions

COMMAND LINE:
./mandelbrot.ocaml-6.ocaml_run 16000

(BINARY) PROGRAM OUTPUT NOT SHOWN

Revised BSD license

  Home   Conclusions   License   Play