/mobile Handheld Friendly website
Ubuntu : Intel® Q6600® one core |
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,000 | 1.37 | 1.37 | 660 | 350 | 0% 1% 1% 100% |
| 5,000,000 | 13.62 | 13.63 | 664 | 350 | 0% 0% 0% 100% |
| 50,000,000 | 136.21 | 136.28 | 680 | 350 | 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.
The OCaml native-code compiler, version 4.00.1
For this to work on 32bit we have to set ulimit -s 100
(* The Computer Language Benchmarks Game * http://benchmarksgame.alioth.debian.org/ contributed by Tomasz bla Fortuna *) let size = 503 and n = int_of_string Sys.argv.(1) type channel = { m : Mutex.t; d : int ref } let channel () = let mx = Mutex.create () in Mutex.lock mx; { m = mx; d = ref 0} let rec spawn id i o loop () = let rec thread () = Mutex.lock i.m; if !(i.d) = n then ( print_int (size-id+1); print_newline (); exit 0; ); o.d := !(i.d) + 1; (* Forward token *) Mutex.unlock o.m; thread () in if id > 1 then ( let new_o = if id = 2 then loop else channel () in let f = spawn (id-1) o new_o loop in ignore (Thread.create f ()) ); thread () let _ = let loop, o = channel (), channel () in Mutex.unlock loop.m; Thread.join (Thread.create (spawn size loop o loop) ())
Sun, 03 Feb 2013 03:39:17 GMT MAKE: mv threadring.ocaml-2.ocaml threadring.ocaml-2.ml /usr/local/bin/ocamlopt -noassert -unsafe -nodynlink -inline 100 -thread unix.cmxa threads.cmxa threadring.ocaml-2.ml -o threadring.ocaml-2.ocaml_run File "threadring.ocaml-2.ml", line 1: Warning 24: bad source file name: "Threadring.ocaml-2" is not a valid module name. rm threadring.ocaml-2.ml 0.23s to complete and log all make actions COMMAND LINE: ./threadring.ocaml-2.ocaml_run 50000000 PROGRAM OUTPUT: 292