Debian Codegraph @

lib/newProfile.mli

raw symbols SCIP
1 (************************************************************************)
2 (* * The Rocq Prover / The Rocq Development Team *)
3 (* v * Copyright INRIA, CNRS and contributors *)
4 (* <O___,, * (see version control and CREDITS file for authors & dates) *)
5 (* \VV/ **************************************************************)
6 (* // * This file is distributed under the terms of the *)
7 (* * GNU Lesser General Public License Version 2.1 *)
8 (* * (see LICENSE file for the text of the license) *)
9 (************************************************************************)
10
11 module MiniJson : sig
12 (** Subtype of Yojson.Safe.t *)
13 type t = [
14 | `Intlit of string
15 | `String of string
16 | `Assoc of (string * t) list
17 | `List of t list
18 ]
19
20 val pr : Format.formatter -> t -> unit
21 end
22
23 module Counters : sig
24 type t
25
26 val get : unit -> t
27
28 val zero : t
29
30 val (+) : t -> t -> t
31
32 val (-) : t -> t -> t
33
34 val print : t -> Pp.t
35 end
36
37 val profile : string -> ?args:(unit -> (string * MiniJson.t) list) -> (unit -> 'a) -> unit -> 'a
38 (** Profile the given function.
39
40 [args] is called only if profiling is active, it is used to
41 produce additional annotations.
42 *)
43
44 val is_profiling : unit -> bool
45
46 type settings =
47 { output : Format.formatter;
48 fname : string;
49 }
50
51 val init : settings -> unit
52 (** Profiling must not be active.
53 Activates profiling with a fresh state. *)
54
55 val finish : unit -> unit
56 (** Profiling must be active.
57 Deactivates profiling. *)
58
59 type accu
60 (** Profiling state accumulator. *)
61
62 val pause : unit -> accu option
63 (** Returns [None] if profiling is inactive.
64 Deactivates profiling if it is active, returning the current state. *)
65
66 val resume : accu -> unit
67 (** Profiling must not be active.
68 Activates profiling with the given state. *)
69
70 type sums = (float * int) CString.Map.t
71 (** Timings for sub-events: for each event, how long it took and how many times it was called. *)
72
73 val empty_sums : sums
74
75 val sums_union : sums -> sums -> sums
76
77 val with_profiling : (unit -> 'a) -> MiniJson.t list * sums * 'a
78 (** Runs the given function with profiling active and returns the
79 produced events and sum times of subevents. *)
80
81 val insert_results : MiniJson.t list -> sums -> unit
82 (** Profiling must be active.
83 Outputs the given events and includes the sum times in the current event. *)
84
85 val pptime : Format.formatter -> float -> unit
86 (** Pretty print a time given in seconds using smaller units as needed. *)
87
88 (** Custom outputs *)
89
90 val format_header : Format.formatter -> unit
91 (** Output header for profile files *)
92
93 val format_footer : Format.formatter -> unit
94 (** Output footer for profile files and flushes the formatter. *)