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.483.492,752282  0% 1% 2% 100%
5,000,00034.1034.126,624282  1% 1% 0% 100%
50,000,000340.10340.348,600282  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 program source code

(* The Computer Language Benchmarks Game
 * http://benchmarksgame.alioth.debian.org/
   Contributed by Charles Martin. *)

let size = 503

let n = int_of_string Sys.argv.(1)

let run id ichan ochan =
  let rec loop () =
    let token = Event.sync (Event.receive ichan) in
    if token = n then (print_int id; print_newline (); exit 0)
    else (Event.sync (Event.send ochan (token + 1)); loop ())
  in Thread.create loop ()

let () =
  let channels =
    Array.init size
      (fun _ -> Event.new_channel ()) in
  let threads =
    Array.init size
      (fun i -> run (i + 1) channels.(i) channels.((i + 1) mod size)) in
  Event.sync (Event.send channels.(0) 0);
  Thread.join threads.(0)

 make, command-line, and program output logs

Thu, 12 Sep 2013 22:56:25 GMT

MAKE:
mv threadring.ocaml threadring.ml
/usr/local/bin/ocamlopt -noassert -unsafe -nodynlink -inline 100 -thread unix.cmxa threads.cmxa threadring.ml -o threadring.ocaml_run
rm threadring.ml
0.23s to complete and log all make actions

COMMAND LINE:
./threadring.ocaml_run 50000000

PROGRAM OUTPUT:
292

Revised BSD license

  Home   Conclusions   License   Play