summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValentin Gatien-Baron <vgatien-baron@janestreet.com>2017-01-31 17:49:53 -0500
committerValentin Gatien-Baron <vgatien-baron@janestreet.com>2017-02-01 16:24:20 -0500
commit39555a7f3242c93b37375f62d1974ac4064d9f7a (patch)
tree8ca063cbb92fafd26febc24a35bd1f2cf9d67b6a
parent81dafd7ee2236411c6d01444c4f3fd0991af3a8f (diff)
downloadocaml-39555a7f3242c93b37375f62d1974ac4064d9f7a.tar.gz
in -dtimings, include the time spent in -ppx, and the time spent demarshalling the output of -pp
-rw-r--r--driver/pparse.ml23
-rw-r--r--utils/timings.ml10
-rw-r--r--utils/timings.mli4
3 files changed, 24 insertions, 13 deletions
diff --git a/driver/pparse.ml b/driver/pparse.ml
index 5fbaa91e42..b00ded4077 100644
--- a/driver/pparse.ml
+++ b/driver/pparse.ml
@@ -38,7 +38,7 @@ let preprocess sourcefile =
match !Clflags.preprocessor with
None -> sourcefile
| Some pp ->
- Timings.(time (Preprocessing sourcefile))
+ Timings.(time (Dash_pp sourcefile))
(call_external_preprocessor sourcefile) pp
@@ -166,6 +166,7 @@ let parse (type a) (kind : a ast_kind) lexbuf : a =
let file_aux ppf ~tool_name inputfile (type a) parse_fun invariant_fun
(kind : a ast_kind) =
let ast_magic = magic_of_kind kind in
+ let source_file = !Location.input_name in
let (ic, is_ast_file) = open_and_check_magic inputfile ast_magic in
let ast =
try
@@ -181,12 +182,15 @@ let file_aux ppf ~tool_name inputfile (type a) parse_fun invariant_fun
Location.input_name := inputfile;
let lexbuf = Lexing.from_channel ic in
Location.init lexbuf inputfile;
- parse_fun lexbuf
+ Timings.(time_call (Parser source_file)) (fun () ->
+ parse_fun lexbuf)
end
with x -> close_in ic; raise x
in
close_in ic;
- let ast = apply_rewriters ~restore:false ~tool_name kind ast in
+ let ast =
+ Timings.(time_call (Dash_ppx source_file)) (fun () ->
+ apply_rewriters ~restore:false ~tool_name kind ast) in
if is_ast_file || !Clflags.all_ppx <> [] then invariant_fun ast;
ast
@@ -212,8 +216,7 @@ let parse_file ~tool_name invariant_fun apply_hooks kind ppf sourcefile =
Location.input_name := sourcefile;
let inputfile = preprocess sourcefile in
let ast =
- let parse_fun = Timings.(time (Parsing sourcefile)) (parse kind) in
- try file_aux ppf ~tool_name inputfile parse_fun invariant_fun kind
+ try file_aux ppf ~tool_name inputfile (parse kind) invariant_fun kind
with exn ->
remove_preprocessed inputfile;
raise exn
@@ -230,8 +233,10 @@ module InterfaceHooks = Misc.MakeHooks(struct
end)
let parse_implementation ppf ~tool_name sourcefile =
- parse_file ~tool_name Ast_invariants.structure
- ImplementationHooks.apply_hooks Structure ppf sourcefile
+ Timings.(time_call (Parsing sourcefile)) (fun () ->
+ parse_file ~tool_name Ast_invariants.structure
+ ImplementationHooks.apply_hooks Structure ppf sourcefile)
let parse_interface ppf ~tool_name sourcefile =
- parse_file ~tool_name Ast_invariants.signature
- InterfaceHooks.apply_hooks Signature ppf sourcefile
+ Timings.(time_call (Parsing sourcefile)) (fun () ->
+ parse_file ~tool_name Ast_invariants.signature
+ InterfaceHooks.apply_hooks Signature ppf sourcefile)
diff --git a/utils/timings.ml b/utils/timings.ml
index e569c21b75..64b7f61a1a 100644
--- a/utils/timings.ml
+++ b/utils/timings.ml
@@ -24,7 +24,9 @@ type source_provenance =
type compiler_pass =
| All
| Parsing of file
- | Preprocessing of file
+ | Parser of file
+ | Dash_pp of file
+ | Dash_ppx of file
| Typing of file
| Transl of file
| Generate of file
@@ -115,7 +117,9 @@ let kind_name = function
let pass_name = function
| All -> "all"
| Parsing file -> Printf.sprintf "parsing(%s)" file
- | Preprocessing file -> Printf.sprintf "preprocessing(%s)" file
+ | Parser file -> Printf.sprintf "parser(%s)" file
+ | Dash_pp file -> Printf.sprintf "-pp(%s)" file
+ | Dash_ppx file -> Printf.sprintf "-ppx(%s)" file
| Typing file -> Printf.sprintf "typing(%s)" file
| Transl file -> Printf.sprintf "transl(%s)" file
| Generate file -> Printf.sprintf "generate(%s)" file
@@ -148,6 +152,6 @@ let print ppf =
| Some duration ->
Format.fprintf ppf "%s: %.03fs@." (pass_name pass) duration
| None ->
- Format.fprintf ppf "%s: running since %.03fs@." (pass_name pass)
+ Format.fprintf ppf "%s: running for %.03fs@." (pass_name pass)
(current_time -. start))
(timings_list ())
diff --git a/utils/timings.mli b/utils/timings.mli
index 99ef65562b..1983a9ce4a 100644
--- a/utils/timings.mli
+++ b/utils/timings.mli
@@ -26,7 +26,9 @@ type source_provenance =
type compiler_pass =
| All
| Parsing of file
- | Preprocessing of file
+ | Parser of file
+ | Dash_pp of file
+ | Dash_ppx of file
| Typing of file
| Transl of file
| Generate of file