package hdr_histogram

  1. Overview
  2. Docs

Source file hdr_histogram.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
open Ctypes
module Types = Types_generated

type t = Types.hdr_histogram structure ptr

let init ~lowest_discernible_value ~highest_trackable_value ~significant_figures
    =
  let h =
    allocate (ptr Types.hdr_histogram) (from_voidp Types.hdr_histogram null)
  in
  let res =
    C.Function.hdr_init
      (Int64.of_int lowest_discernible_value)
      (Int64.of_int highest_trackable_value)
      significant_figures h
  in
  assert (res = 0);
  let h' : t = !@h in
  h'

let record_value h v = C.Function.hdr_record_value h (Int64.of_int v)
let close h = C.Function.hdr_close h

let value_at_percentile h p =
  Int64.to_int @@ C.Function.hdr_value_at_percentile h p

let max h = Int64.to_int @@ C.Function.hdr_max h
let min h = Int64.to_int @@ C.Function.hdr_min h
let mean h = C.Function.hdr_mean h
let stddev h = C.Function.hdr_stddev h
let memory_size h = Unsigned.Size_t.to_int @@ C.Function.hdr_get_memory_size h