package bechamel

  1. Overview
  2. Docs
Yet Another Benchmark in OCaml

Install

dune-project
 Dependency

Authors

Maintainers

Sources

bechamel-0.4.0.tbz
sha256=e9d26f9201fd98f860e9b3afad7a5d520f04ae9c95bea070f5d0ac2c26abff4d
sha512=eac5f8aa192d66ba70a28ce44bdbf6a849ff1a82a8efbaab87067e2ee06c00bcc04e6f16923948857eec41cb171e3915d1e4cb751be7cf95d4521d5dbe4dd858

doc/src/bechamel/measurement_raw.ml.html

Source file measurement_raw.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
type t = { run : float; measures : float array; labels : string array }

let make ~measures ~labels run =
  if Array.length measures <> Array.length labels then
    invalid_arg "Measures and labels differ"
  else { run; measures; labels }

exception Find

let get_index ~label m =
  let i0 = ref 0 in
  try
    while !i0 < Array.length m.labels do
      if String.equal m.labels.(!i0) label then raise Find;
      incr i0
    done;
    raise Not_found
  with Find -> !i0

let exists ~label m =
  if String.equal label Measure.run then true
  else
    let yes = ref false in
    for i = 0 to Array.length m.labels - 1 do
      if String.equal m.labels.(i) label then yes := true
    done;
    !yes

let run t = t.run

let get ~label m =
  if label = Measure.run then m.run
  else
    let i = get_index ~label m in
    m.measures.(i)

let pp ppf x =
  Fmt.pf ppf "{ @[<hov>run = %f;@ " x.run;
  for i = 0 to Array.length x.labels - 1 do
    Fmt.pf ppf "%s = %f;@ " x.labels.(i) x.measures.(i)
  done;
  Fmt.pf ppf "@] }"