diff options
author | 2017-12-11 05:21:05 -0500 | |
---|---|---|
committer | 2017-12-14 12:19:02 -0500 | |
commit | 90d79c5656c394909ffc9343b903dd1231abd7a4 (patch) | |
tree | 0aec14a5e6547173a47482a3e4d10780828a905d /plugins/ltac/profile_ltac.ml | |
parent | 6734614d8ace6860e3deb1861611ba4b012cfae1 (diff) |
Add named timers to LtacProf
I'm not sure if they belong in profile_ltac, or in extratactics, or,
perhaps, in a separate plugin. But I'd find it very useful to have a
version of `time` that works on constr evaluation, which is what this
commit provides.
I'm not sure that I've picked good naming conventions for the tactics,
either.
Diffstat (limited to 'plugins/ltac/profile_ltac.ml')
-rw-r--r-- | plugins/ltac/profile_ltac.ml | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/plugins/ltac/profile_ltac.ml b/plugins/ltac/profile_ltac.ml index 5225420dc..97f43eaa8 100644 --- a/plugins/ltac/profile_ltac.ml +++ b/plugins/ltac/profile_ltac.ml @@ -397,6 +397,27 @@ let reset_profile () = reset_profile_tmp (); data := SM.empty +(* ****************************** Named timers ****************************** *) + +let timer_data = ref M.empty + +let timer_name = function + | Some v -> v + | None -> "" + +let restart_timer name = + timer_data := M.add (timer_name name) (System.get_time ()) !timer_data + +let get_timer name = + try M.find (timer_name name) !timer_data + with Not_found -> System.get_time () + +let finish_timing ~prefix name = + let tend = System.get_time () in + let tstart = get_timer name in + Feedback.msg_info(str prefix ++ pr_opt str name ++ str " ran for " ++ + System.fmt_time_difference tstart tend) + (* ******************** *) let print_results_filter ~cutoff ~filter = |