Skip to content

Commit 895af4f

Browse files
authored
Merge pull request #3974 from mtzguido/stats_record
Tactics: introduce stats_record
2 parents a9604fa + 5b64e45 commit 895af4f

File tree

5 files changed

+21
-0
lines changed

5 files changed

+21
-0
lines changed

src/tactics/FStarC.Tactics.V2.Basic.fst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3065,3 +3065,7 @@ let call_subtac_tm (g:env) (f_tm : term) (_u:universe) (goal_ty : typ) : tac (op
30653065
return (Some w, [])
30663066
| issues, _ ->
30673067
return (None, issues)
3068+
3069+
let stats_record (a:'a) (wp:'b) (s:string) (f : tac 'c) : tac 'c =
3070+
mk_tac (fun ps ->
3071+
Stats.record s (fun () -> run f ps))

src/tactics/FStarC.Tactics.V2.Basic.fsti

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,5 @@ val log_issues : list Errors.issue -> tac unit
158158

159159
val call_subtac : env -> tac unit -> universe -> typ -> refl_tac term
160160
val call_subtac_tm : env -> term -> universe -> typ -> refl_tac term
161+
162+
val stats_record (a:'a) (wp:'b) (s:string) (f : tac 'c) : tac 'c

src/tactics/FStarC.Tactics.V2.Primops.fst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,4 +271,10 @@ let ops = [
271271

272272
mk_tac_step_4 0 "call_subtac_tm"
273273
call_subtac_tm call_subtac_tm;
274+
275+
mk_tac_step_4 1 "stats_record"
276+
#e_any #e_any #_ #(TI.e_tactic_thunk e_any) #e_any
277+
#NBET.e_any #NBET.e_any #_ #(TI.e_tactic_nbe_thunk NBET.e_any) #NBET.e_any
278+
stats_record
279+
stats_record;
274280
]

ulib/FStar.Stubs.Tactics.V2.Builtins.fsti

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,3 +644,9 @@ val call_subtac_tm
644644
(g:env) (t : term) (u:universe)
645645
(goal_ty : term{typing_token g goal_ty (E_Total, pack_ln (Tv_Type u))})
646646
: Tac (ret_t (w:term{typing_token g w (E_Total, goal_ty)}))
647+
648+
(* This will call the function [f] and log the time it takes under the stat key
649+
[s]. The stats can be printed by running F* with `--stats true`. Other than
650+
that, there is no observable difference from calling [f]. We could also expose
651+
a pure version of this function. *)
652+
val stats_record #a #wp (s : string) ($f : unit -> TAC a wp) : TAC a wp

ulib/ml/plugin/FStarC_Tactics_V2_Builtins.ml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,3 +180,6 @@ let call_subtac g (t : unit -> unit __tac) u ty =
180180
from_tac_4 "B.call_subtac" B.call_subtac g t u ty
181181

182182
let call_subtac_tm = from_tac_4 "B.call_subtac_tm" B.call_subtac_tm
183+
184+
let stats_record (s : string) (f : unit -> 'c __tac) : 'c __tac =
185+
from_tac_2 "B.stats_record" (B.stats_record () ()) s (to_tac_0 (f ()))

0 commit comments

Comments
 (0)