package bechamel-perf

  1. Overview
  2. Docs

Source file bechamel_perf.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
module Perf = Mperf

module Make (X : sig
  val kind : Perf.Attr.Kind.t
end) =
struct
  type witness = Perf.t

  let load witness = Perf.enable witness
  let unload witness = Perf.disable witness
  let make () = Perf.make (Perf.Attr.make X.kind)

  let label witness =
    let kind = Perf.kind witness in
    Perf.Attr.Kind.to_string kind

  let unit = label
  let get witness = Int64.to_float (Perf.read witness)
end

module Cycles = Make (struct
  let kind = Perf.Attr.Kind.Cycles
end)

module Instructions = Make (struct
  let kind = Perf.Attr.Kind.Instructions
end)

module Cache_references = Make (struct
  let kind = Perf.Attr.Kind.Cache_references
end)

module Cache_misses = Make (struct
  let kind = Perf.Attr.Kind.Cache_misses
end)

module Branch_instructions = Make (struct
  let kind = Perf.Attr.Kind.Branch_instructions
end)

module Branch_misses = Make (struct
  let kind = Perf.Attr.Kind.Branch_misses
end)

module Bus_cycles = Make (struct
  let kind = Perf.Attr.Kind.Bus_cycles
end)

module Stalled_cycles_frontend = Make (struct
  let kind = Perf.Attr.Kind.Stalled_cycles_frontend
end)

module Stalled_cycles_backend = Make (struct
  let kind = Perf.Attr.Kind.Stalled_cycles_backend
end)

module Ref_cpu_cycles = Make (struct
  let kind = Perf.Attr.Kind.Ref_cpu_cycles
end)

module Cpu_clock = Make (struct
  let kind = Perf.Attr.Kind.Cpu_clock
end)

module Task_clock = Make (struct
  let kind = Perf.Attr.Kind.Task_clock
end)

module Page_faults = Make (struct
  let kind = Perf.Attr.Kind.Page_faults
end)

module Context_switches = Make (struct
  let kind = Perf.Attr.Kind.Context_switches
end)

module Cpu_migrations = Make (struct
  let kind = Perf.Attr.Kind.Cpu_migrations
end)

module Page_faults_min = Make (struct
  let kind = Perf.Attr.Kind.Page_faults_min
end)

module Page_faults_maj = Make (struct
  let kind = Perf.Attr.Kind.Page_faults_maj
end)

module Alignment_faults = Make (struct
  let kind = Perf.Attr.Kind.Alignment_faults
end)

module Emulation_faults = Make (struct
  let kind = Perf.Attr.Kind.Emulation_faults
end)

module Dummy = Make (struct
  let kind = Perf.Attr.Kind.Dummy
end)

open Bechamel

module Extension = struct
  include Toolkit.Extension

  (* XXX(dinosaure): only software measures. *)

  let cpu_clock = Measure.register (module Cpu_clock)
  let task_clock = Measure.register (module Task_clock)
  let page_faults = Measure.register (module Page_faults)
  let context_switches = Measure.register (module Context_switches)
  let cpu_migrations = Measure.register (module Cpu_migrations)
  let page_faults_min = Measure.register (module Page_faults_min)
  let page_faults_maj = Measure.register (module Page_faults_maj)
  let alignment_faults = Measure.register (module Alignment_faults)
  let emulation_faults = Measure.register (module Emulation_faults)
  let dummy = Measure.register (module Dummy)
end

module Instance = struct
  include Toolkit.Instance

  let cpu_clock = Measure.instance (module Cpu_clock) Extension.cpu_clock
  let task_clock = Measure.instance (module Task_clock) Extension.task_clock
  let page_faults = Measure.instance (module Page_faults) Extension.page_faults

  let context_switches =
    Measure.instance (module Context_switches) Extension.context_switches

  let cpu_migrations =
    Measure.instance (module Cpu_migrations) Extension.cpu_migrations

  let page_faults_min =
    Measure.instance (module Page_faults_min) Extension.page_faults_min

  let page_faults_maj =
    Measure.instance (module Page_faults_maj) Extension.page_faults_maj

  let alignment_faults =
    Measure.instance (module Alignment_faults) Extension.alignment_faults

  let emulation_faults =
    Measure.instance (module Emulation_faults) Extension.emulation_faults

  let dummy = Measure.instance (module Dummy) Extension.dummy
end