[reporting][perf] Add PerfStats support for ad-hoc timers

Summary:
Perf reporting can now be registered at one point (with desired start real and cpu times) and triggered later
  - This is accomplished by storing perf file names in a hashtable mapping to the reporting function
  - New `stats_kind` parameter that is either Time, Memory, or TimeAndMemory, where Time requires a Unix.process_times and an Mtime_clock.counter to be passed in, but TimeAndMemory just uses the time from the start of the process.

Reviewed By: dulmarod

Differential Revision: D7337158

fbshipit-source-id: 94699cd
master
Varun Arora 7 years ago committed by Facebook Github Bot
parent c296c06996
commit d746b10bf3

@ -866,11 +866,6 @@ let get_summary_iterator () =
iterate iterate
let register_perf_stats_report () =
let filename = F.sprintf "%s.json" Config.perf_stats_prefix in
PerfStats.register_report_at_exit filename PerfStats.Reporting
(** Although the out_file is an Option type, the None option is strictly meant for the (** Although the out_file is an Option type, the None option is strictly meant for the
logs format_kind, and all other formats should contain an outfile value. *) logs format_kind, and all other formats should contain an outfile value. *)
let mk_format format_kind fname = let mk_format format_kind fname =
@ -969,6 +964,17 @@ let pp_summary_and_issues formats_by_report_kind issue_formats =
finalize_and_close_files formats_by_report_kind stats finalize_and_close_files formats_by_report_kind stats
let register_perf_stats_report () =
let fname = F.sprintf "%s.json" Config.perf_stats_prefix in
let rtime_span, initial_times = (Mtime_clock.counter (), Unix.times ()) in
PerfStats.register_report (PerfStats.Time (rtime_span, initial_times)) fname PerfStats.Reporting
let report_perf_stats () =
let fname = F.sprintf "%s.json" Config.perf_stats_prefix in
PerfStats.get_reporter fname PerfStats.Reporting ()
let main ~report_json = let main ~report_json =
let issue_formats = init_issues_format_list report_json in let issue_formats = init_issues_format_list report_json in
let formats_by_report_kind = let formats_by_report_kind =
@ -979,8 +985,9 @@ let main ~report_json =
in in
register_perf_stats_report () ; register_perf_stats_report () ;
init_files formats_by_report_kind ; init_files formats_by_report_kind ;
match Config.from_json_report with ( match Config.from_json_report with
| Some fname -> | Some fname ->
pp_json_report_by_report_kind formats_by_report_kind fname pp_json_report_by_report_kind formats_by_report_kind fname
| None -> | None ->
pp_summary_and_issues formats_by_report_kind issue_formats pp_summary_and_issues formats_by_report_kind issue_formats ) ;
report_perf_stats ()

Loading…
Cancel
Save