Debian Codegraph @

plugins/ltac/profile_ltac_tactics.mlg

raw
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 {
12
13 (** Ltac profiling entrypoints *)
14
15 open Profile_tactic
16 open Stdarg
17
18 }
19
20 DECLARE PLUGIN "rocq-runtime.plugins.ltac"
21
22 {
23
24 let tclSET_PROFILING b =
25 Proofview.tclLIFT (Proofview.NonLogical.make (fun () -> set_profiling b))
26
27 let tclRESET_PROFILE =
28 Proofview.tclLIFT (Proofview.NonLogical.make reset_profile)
29
30 let tclSHOW_PROFILE ~cutoff =
31 Proofview.tclLIFT (Proofview.NonLogical.make (fun () -> print_results ~cutoff))
32
33 let tclSHOW_PROFILE_TACTIC s =
34 Proofview.tclLIFT (Proofview.NonLogical.make (fun () -> print_results_tactic s))
35
36 let tclRESTART_TIMER s =
37 Proofview.tclLIFT (Proofview.NonLogical.make (fun () -> restart_timer s))
38
39 let tclFINISH_TIMING ?(prefix="Timer") (s : string option) =
40 Proofview.tclLIFT (Proofview.NonLogical.make (fun () -> finish_timing ~prefix s))
41
42 }
43
44 TACTIC EXTEND start_ltac_profiling
45 | [ "start" "ltac" "profiling" ] -> { tclSET_PROFILING true }
46 END
47
48 TACTIC EXTEND stop_ltac_profiling
49 | [ "stop" "ltac" "profiling" ] -> { tclSET_PROFILING false }
50 END
51
52 TACTIC EXTEND reset_ltac_profile
53 | [ "reset" "ltac" "profile" ] -> { tclRESET_PROFILE }
54 END
55
56 TACTIC EXTEND show_ltac_profile
57 | [ "show" "ltac" "profile" ] -> { tclSHOW_PROFILE ~cutoff:None }
58 | [ "show" "ltac" "profile" "cutoff" integer(n) ] -> { tclSHOW_PROFILE ~cutoff:(Some (float_of_int n)) }
59 | [ "show" "ltac" "profile" string(s) ] -> { tclSHOW_PROFILE_TACTIC s }
60 END
61
62 TACTIC EXTEND restart_timer
63 | [ "restart_timer" string_opt(s) ] -> { tclRESTART_TIMER s }
64 END
65
66 TACTIC EXTEND finish_timing
67 | [ "finish_timing" string_opt(s) ] -> { tclFINISH_TIMING ~prefix:"Timer" s }
68 | [ "finish_timing" "(" string(prefix) ")" string_opt(s) ] -> { tclFINISH_TIMING ~prefix s }
69 END
70
71 VERNAC COMMAND EXTEND ResetLtacProfiling CLASSIFIED AS SIDEFF
72 | [ "Reset" "Ltac" "Profile" ] -> { reset_profile () }
73 END
74
75 VERNAC COMMAND EXTEND ShowLtacProfile CLASSIFIED AS QUERY
76 | [ "Show" "Ltac" "Profile" ] -> { print_results ~cutoff:None }
77 | [ "Show" "Ltac" "Profile" "CutOff" integer(n) ] -> { print_results ~cutoff:(Some (float_of_int n)) }
78 END
79
80 VERNAC COMMAND EXTEND ShowLtacProfileTactic CLASSIFIED AS QUERY
81 | [ "Show" "Ltac" "Profile" string(s) ] -> { print_results_tactic s }
82 END