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,0006.555.104,816282  55% 6% 7% 53%
5,000,00070.6457.795,372282  35% 19% 20% 35%
50,000,000715.24601.955,040282  27% 26% 27% 27%

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

Mon, 16 Mar 2015 17:10:55 GMT

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

COMMAND LINE:
./threadring.ocaml_run 50000000

PROGRAM OUTPUT:
292

Revised BSD license

  Home   Conclusions   License   Play