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,0003.882.803,000296  9% 42% 42% 11%
5,000,00038.5828.553,000296  37% 13% 14% 38%
50,000,000387.24296.603,000296  25% 24% 23% 25%

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.02.1

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

Mon, 16 Mar 2015 01:34:10 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 9, characters 11-23:
Warning 3: deprecated: Array.create
Use Array.make instead.
rm threadring.ocaml-3.ml
0.43s 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