Skip to content

Commit

Permalink
Timing information.
Browse files Browse the repository at this point in the history
  • Loading branch information
lukstafi committed Feb 18, 2014
1 parent 782be94 commit 5c76a43
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 0 deletions.
Binary file modified doc/invargent-manual.pdf
Binary file not shown.
3 changes: 3 additions & 0 deletions doc/invargent-manual.tm
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,9 @@
<item*|<verbatim|-inform>>Print type schemes of toplevel definitions as
they are inferred.

<item*|<verbatim|-time>>Print the time it took to infer type schemes of
toplevel definitions.

<item*|<verbatim|-no_sig>>Do not generate the <verbatim|.gadti> file.

<item*|<verbatim|-no_ml>>Do not generate the <verbatim|.ml> file.
Expand Down
20 changes: 20 additions & 0 deletions src/Infer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
let annotating_fun = ref true
let annotating_letin = ref false
let inform_toplevel = ref false
let time_toplevel = ref false
let merge_rec_nonrec = ref true

open Defs
Expand Down Expand Up @@ -744,6 +745,8 @@ let prepare_scheme phi res =
VarSet.union vs rvs, phi

let infer_prog solver prog =
let ntime = ref (Sys.time ()) in
let start_time = !ntime in
let gamma = ref [] in
let update_new_ex_types q new_ex_types sb sb_chi =
let more_items = ref [] in
Expand Down Expand Up @@ -851,6 +854,11 @@ let infer_prog solver prog =
if !inform_toplevel
then Format.printf
"@[<2>val@ %s :@ %a@]@\n%!" x pr_typscheme typ_sch;
if !inform_toplevel && !time_toplevel
then (
let time = Sys.time () in
Format.printf "(t=%.3fs)@\n" (time -. !ntime);
ntime := time);
(match pat_loc with
| Some lc ->
ex_items @
Expand Down Expand Up @@ -931,6 +939,11 @@ let infer_prog solver prog =
if !inform_toplevel
then Format.printf
"@[<2>val@ %s :@ %a@]@\n%!" x pr_typscheme typ_sch;
if !inform_toplevel && !time_toplevel
then (
let time = Sys.time () in
Format.printf "(t=%.3fs)@\n" (time -. !ntime);
ntime := time);
x, typ_sch
else fun (x, res) ->
let res = subst_typ exsb res in
Expand Down Expand Up @@ -970,12 +983,19 @@ let infer_prog solver prog =
if !inform_toplevel
then Format.printf
"@[<2>val@ %s :@ %a@]@\n%!" x pr_typscheme typ_sch;
if !inform_toplevel && !time_toplevel
then (
let time = Sys.time () in
Format.printf "(t=%.3fs)@\n" (time -. !ntime);
ntime := time);
x, typ_sch in
let typ_schs = List.map typ_sch_ex env in
gamma := typ_schs @ !gamma;
ex_items @ List.rev !more_items
@ [ILetVal (docu, p, e, top_sch, typ_schs, tests, elim_extypes, loc)]
) prog in
if !time_toplevel
then Format.printf "@\nTotal time %.3fs@\n" (Sys.time () -. start_time);
List.rev !gamma, items


Expand Down
1 change: 1 addition & 0 deletions src/Infer.mli
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
val annotating_fun : bool ref
val annotating_letin : bool ref
val inform_toplevel : bool ref
val time_toplevel : bool ref

(** Each disjunct stores a trigger to be called when other disjuncts
are eliminated during normalization-simplification. *)
Expand Down
2 changes: 2 additions & 0 deletions src/InvarGenT.ml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ let main () =
let cli = [
"-inform", Arg.Set Infer.inform_toplevel,
"Print type schemes of toplevel definitions as they are inferred";
"-time", Arg.Set Infer.time_toplevel,
"Print the time it took to infer type schemes of toplevel definitions";
"-no_sig", Arg.Clear do_sig,
"Do not generate the `.gadti` file";
"-no_ml", Arg.Clear do_ml,
Expand Down

0 comments on commit 5c76a43

Please sign in to comment.