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
500,0001.541.543,004296  0% 0% 1% 100%
5,000,00015.1915.203,004296  0% 0% 0% 100%
50,000,000151.64151.713,004296  0% 0% 0% 100%

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

Read thread-ring benchmark to see what this program should do.

 notes

The OCaml native-code compiler, version 4.01.0

For this to work on 32bit we have to set ulimit -s 100

 thread-ring OCaml #3 program source code

(* The Computer Language Benchmarks Game
 * http://benchmarksgame.alioth.debian.org/
   contributed by Tomasz bla Fortuna *)

let size, n = 503, int_of_string Sys.argv.(1)
let mutex = 
  let f _ = let m = Mutex.create () in Mutex.lock m; m in
  Array.init size f
and data = Array.create size 0

let run id idata odata =
  let rec loop () =
    Mutex.lock mutex.(idata);
    if data.(idata) = n then (
      print_int id; print_newline (); exit 0;
    ) else (
      data.(odata) <- data.(idata) + 1;
      Mutex.unlock mutex.(odata);
      loop ();
    )
  in Thread.create loop ()

let _ =
  let thread =
    Array.init size
      (fun i -> run (i + 1) i ((i + 1) mod size)) in
  Mutex.unlock mutex.(0);
  Thread.join thread.(0)



 make, command-line, and program output logs

Thu, 12 Sep 2013 22:33:53 GMT

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

COMMAND LINE:
./threadring.ocaml-3.ocaml_run 50000000

PROGRAM OUTPUT:
292

Revised BSD license

  Home   Conclusions   License   Play