Print timing information in InferClang debug mode.

Reviewed By: akotulski

Differential Revision: D3133005

fb-gh-sync-id: cedfc58
fbshipit-source-id: cedfc58
master
Cristiano Calcagno 9 years ago committed by Facebook Github Bot 0
parent a386cf7dbf
commit 031f433b15

@ -116,11 +116,17 @@ let validate_decl_from_stdin () =
let do_run source_path ast_path = let do_run source_path ast_path =
let init_time = Unix.gettimeofday () in
let print_elapsed () =
let elapsed = Unix.gettimeofday () -. init_time in
Printf.printf "Elapsed: %07.3f seconds.\n" elapsed in
try try
let ast_filename, ast_decl = let ast_filename, ast_decl =
match ast_path with match ast_path with
| Some path -> path, validate_decl_from_file path | Some path ->
| None -> "stdin of " ^ source_path, validate_decl_from_stdin () in path, validate_decl_from_file path
| None ->
"stdin of " ^ source_path, validate_decl_from_stdin () in
let decl_index, stmt_index, type_index = Clang_ast_main.index_node_pointers ast_decl in let decl_index, stmt_index, type_index = Clang_ast_main.index_node_pointers ast_decl in
CFrontend_config.pointer_decl_index := decl_index; CFrontend_config.pointer_decl_index := decl_index;
@ -129,11 +135,14 @@ let do_run source_path ast_path =
CFrontend_config.json := ast_filename; CFrontend_config.json := ast_filename;
CLocation.check_source_file source_path; CLocation.check_source_file source_path;
let source_file = CLocation.source_file_from_path source_path in let source_file = CLocation.source_file_from_path source_path in
print_endline ("Start translation of AST from " ^ !CFrontend_config.json); Printf.printf "Start translation of AST from %s\n" !CFrontend_config.json;
CFrontend.do_source_file source_file ast_decl; CFrontend.do_source_file source_file ast_decl;
print_endline ("End translation AST file " ^ !CFrontend_config.json ^ "... OK!") Printf.printf "End translation AST file %s... OK!\n" !CFrontend_config.json;
print_elapsed ();
with with
(Yojson.Json_error s) as exc -> Printing.log_err "%s\n" s; (Yojson.Json_error s) as exc ->
Printing.log_err "%s\n" s;
print_elapsed ();
raise exc raise exc
let () = let () =
@ -144,5 +153,7 @@ let () =
print_usage_exit ()) print_usage_exit ())
else else
match !CFrontend_config.source_file with match !CFrontend_config.source_file with
| Some path -> do_run path !CFrontend_config.ast_file | Some path ->
| None -> assert false do_run path !CFrontend_config.ast_file
| None ->
assert false

Loading…
Cancel
Save