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
2,000Make Error  510   

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

Read pidigits benchmark to see what this program should do.

 notes

The OCaml native-code compiler, version 4.02.1

 pidigits OCaml #2 program source code

(* The Computer Language Benchmarks Game

 * http://benchmarksgame.alioth.debian.org/

 *

 * contributed by Christophe TROESTLER

 * modified by Matías Giovannini

 *)
open Printf
open Big_int

let ( +$ ) = add_big_int
let ( *$ ) = mult_int_big_int
let ( /$ ) = div_big_int

(* Entier part of the linear fractional transform qrst of x *)
let ext (q,r,s,t) x = int_of_big_int ((x *$ q +$ r) /$ (x *$ s +$ t))

(* Multiply small int matrix qrst by big int matrix qrst' (small on left) *)
let mml (q,r,s,t) (q',r',s',t') =
  q *$ q'  +$  r *$ s',  q *$ r'  +$  r *$ t',
  s *$ q'  +$  t *$ s',  s *$ r'  +$  t *$ t'

(* Multiply big int matrix qrst by small int matrix qrst' (small on right) *)
let mmr (q,r,s,t) (q',r',s',t') =
  q' *$ q  +$  s' *$ r,  r' *$ q  +$  t' *$ r,
  q' *$ s  +$  s' *$ t,  r' *$ s  +$  t' *$ t

let unit = (unit_big_int,zero_big_int,zero_big_int,unit_big_int)

let next z   = ext z 3
and safe z n = ext z 4 == n
and prod z n = mml (10, -10*n, 0, 1) z
and cons z k =
  let den = 2*k + 1 in
  mmr z (k, 2*den, 0, den)

let rec digit k z n row col =
  if n == 0 then printf "%*s\t:%i\n" (10-col) "" (row+col) else
  let d = next z in
  if safe z d then
    if col = 10 then begin
      let row = row + 10 in
      printf "\t:%i\n%i" row d;
      digit k (prod z d) (n-1) row 1
    end else begin
      print_int d;
      digit k (prod z d) (n-1) row (col+1)
    end
  else digit (k+1) (cons z k) n row col

let digits n = digit 1 unit n 0 0

let () = digits (try int_of_string (Array.get Sys.argv 1) with _ -> 27)

 make, command-line, and program output logs

Mon, 16 Mar 2015 03:30:30 GMT

MAKE:
mv pidigits.ocaml-2.ocaml pidigits.ocaml-2.ml
/usr/local/bin/ocamlopt -noassert -unsafe -nodynlink -inline 100 -I /usr/local/lib/ocaml/gmp gmp.cmxa pidigits.ocaml-2.ml -o pidigits.ocaml-2.ocaml_run
File "pidigits.ocaml-2.ml", line 1:
Error: No implementations provided for the following modules:
         Big_int referenced from pidigits.ocaml-2.cmx
make: [pidigits.ocaml-2.ocaml_run] Error 2 (ignored)
rm pidigits.ocaml-2.ml
0.18s to complete and log all make actions

COMMAND LINE:
./pidigits.ocaml-2.ocaml_run 2000

MAKE ERROR 

Revised BSD license

  Home   Conclusions   License   Play