/mobile Handheld Friendly website

 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
5000.160.16?377  6% 0% 0% 94%
3,0005.615.621,128377  0% 1% 0% 100%
5,50018.8518.861,660377  0% 0% 0% 100%

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

Read spectral-norm benchmark to see what this program should do.

 notes

The OCaml native-code compiler, version 4.01.0

 spectral-norm OCaml #2 program source code

(* The Computer Language Benchmarks Game
 * http://benchmarksgame.alioth.debian.org/
 *
 * Contributed by Sebastien Loisel
 * Cleanup by Troestler Christophe
 * Modified by Mauricio Fernandez
 *)

let eval_A i j = 1. /. float((i+j)*(i+j+1)/2+i+1)

let eval_A_times_u u v =
  let n = Array.length v - 1 in
  for i = 0 to  n do
    let vi = ref 0. in
      for j = 0 to n do vi := !vi +. eval_A i j *. u.(j) done;
      v.(i) <- !vi
  done

let eval_At_times_u u v =
  let n = Array.length v -1 in
  for i = 0 to n do
    let vi = ref 0. in
      for j = 0 to n do vi := !vi +. eval_A j i *. u.(j) done;
      v.(i) <- !vi
  done

let eval_AtA_times_u u v =
  let w = Array.make (Array.length u) 0.0 in
  eval_A_times_u u w; eval_At_times_u w v


let () =
  let n = try int_of_string(Array.get Sys.argv 1) with _ ->  2000 in
  let u = Array.make n 1.0  and  v = Array.make n 0.0 in
  for i = 0 to 9 do
    eval_AtA_times_u u v; eval_AtA_times_u v u
  done;

  let vv = ref 0.0  and  vBv = ref 0.0 in
  for i=0 to n-1 do
    vv := !vv +. v.(i) *. v.(i);
    vBv := !vBv +. u.(i) *. v.(i)
  done;
  Printf.printf "%0.9f\n" (sqrt(!vBv /. !vv))

 make, command-line, and program output logs

Thu, 12 Sep 2013 21:57:20 GMT

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

COMMAND LINE:
./spectralnorm.ocaml-2.ocaml_run 5500

PROGRAM OUTPUT:
1.274224153

Revised BSD license

  Home   Conclusions   License   Play