Skip to content

Commit

Permalink
Updating demo file in calculator to fit new Debug interfaces.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandre Maréchal committed Jan 11, 2018
1 parent 7c13b3b commit 1d7475e
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 21 deletions.
15 changes: 13 additions & 2 deletions calculator/demo.ml
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,26 @@ VPL.leq p6 p5;;
They can be enabled separatly in several modules.
The level of details can also be tuned (chosen from [MOutput ; MInput ; Title ; Normal ; Detail].
For instance, to enable the traces in module PLPCore, without details : *)
Debug.enable_one Debug.PLPCore DebugTypes.([MOutput ; MInput ; Title]);;
Join.Debug.enable DebugTypes.([MOutput ; MInput ; Title]);;
PLPCore.Debug.enable DebugTypes.([MOutput ; MInput ; Title]);;

(* By default, traces are stored in a file. To print them on the fly, type *)
Debug.print_enable();;
Debug.set_colors();;

(* Let us do a convex hull, with traces enabled: *)
p3 || p4;;
(* It gives for instance the input PLP tableau, the partition in regions. *)

(* Again, with more detailed traces: *)
Debug.enable_one Debug.PLPCore DebugTypes.([MOutput ; MInput ; Title ; Normal]);;
Join.Debug.enable DebugTypes.([MOutput ; MInput ; Title ; Normal]);;
PLPCore.Debug.enable DebugTypes.([MOutput ; MInput ; Title ; Normal ; Detail]);;
p3 || p4;;

(* Traces for projection *)
Pol.Debug.enable DebugTypes.([MOutput ; MInput ; Title ; Normal ; Detail]);;
Proj.Debug.enable DebugTypes.([MOutput ; MInput ; Title ; Normal ; Detail]);;
Flags.proj := Flags.Proj_PLP (Flags.Float);;

let p3 = p2 |- "z" ;;

46 changes: 27 additions & 19 deletions ocaml/src/misc/Profile.ml
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
(**
This module implements a simple hand-made profiling tool.
To use it, simply instantiate the fonctor Profile with a module D that contains a name. Example :
module MyProfile = Profile(struct let name = "MyModuleName" end)
The "name" variable is used to prefix the name of functions in the report.
*)

module type Type = sig
module D : sig val name : string end

(** Reset the whole map. *)
val reset : unit -> unit

(** Starts the timer for the given function name.
@raise Already_started if that timer was already launched. *)
val start : string -> unit

(** Stops the timer for the given function name.
@raise Not_started if that timer was not launched. *)
val stop : string -> unit

val enable : unit -> unit

val disable : unit -> unit
end

module MapPro = Map.Make(struct type t = string let compare = String.compare end)

type element = {
Expand Down Expand Up @@ -41,25 +68,6 @@ let print_map : unit -> unit
exception Already_started of string
exception Not_started of string

module type Type = sig
module D : sig val name : string end

(** Reset the whole map. *)
val reset : unit -> unit

(** Starts the timer for the given function name.
@raise Already_started if that timer was already launched. *)
val start : string -> unit

(** Stops the timer for the given function name.
@raise Not_started if that timer was not launched. *)
val stop : string -> unit

val enable : unit -> unit

val disable : unit -> unit
end

module Profile (D : sig val name : string end) = struct
module D = D

Expand Down

0 comments on commit 1d7475e

Please sign in to comment.