diff --git a/infer/src/backend/PerfStats.ml b/infer/src/backend/PerfStats.ml index 68f8b2b24..45f3c3f58 100644 --- a/infer/src/backend/PerfStats.ml +++ b/infer/src/backend/PerfStats.ml @@ -37,7 +37,9 @@ type stats_type = | ClangFrontendLinters of SourceFile.t | JavaFrontend of SourceFile.t | PythonFrontend of SourceFile.t + | TotalFrontend | Backend of SourceFile.t + | TotalBackend | Reporting | Driver @@ -76,8 +78,12 @@ let relative_path_of_stats_type stats_type = Config.frontend_stats_dir_name | PythonFrontend _ -> Config.frontend_stats_dir_name + | TotalFrontend -> + Config.frontend_stats_dir_name | Backend _ -> Config.backend_stats_dir_name + | TotalBackend -> + Config.backend_stats_dir_name | Reporting -> Config.reporting_stats_dir_name | Driver -> @@ -97,8 +103,12 @@ let string_of_stats_type = function "java_frontend" | PythonFrontend _ -> "python_frontend" + | TotalFrontend -> + "total_frontend" | Backend _ -> "backend" + | TotalBackend -> + "total_backend" | Reporting -> "reporting" | Driver -> diff --git a/infer/src/backend/PerfStats.mli b/infer/src/backend/PerfStats.mli index 1de5c1059..ff2ca4739 100644 --- a/infer/src/backend/PerfStats.mli +++ b/infer/src/backend/PerfStats.mli @@ -21,7 +21,9 @@ type stats_type = | ClangFrontendLinters of SourceFile.t | JavaFrontend of SourceFile.t | PythonFrontend of SourceFile.t + | TotalFrontend | Backend of SourceFile.t + | TotalBackend | Reporting | Driver diff --git a/infer/src/backend/infer.ml b/infer/src/backend/infer.ml index 1b0b61e81..474615c34 100644 --- a/infer/src/backend/infer.ml +++ b/infer/src/backend/infer.ml @@ -20,8 +20,12 @@ let run driver_mode = let open Driver in run_prologue driver_mode ; let changed_files = read_config_changed_files () in + register_perf_stats_report PerfStats.TotalFrontend ; capture driver_mode ~changed_files ; + PerfStats.get_reporter PerfStats.TotalFrontend () ; + register_perf_stats_report PerfStats.TotalBackend ; analyze_and_report driver_mode ~changed_files ; + PerfStats.get_reporter PerfStats.TotalBackend () ; run_epilogue driver_mode @@ -128,7 +132,9 @@ let () = F.fprintf fmt "of cluster %s" (Filename.basename cluster) in L.environment_info "Starting analysis %a" pp_cluster_opt Config.cluster_cmdline ; - Driver.analyze_and_report Analyze ~changed_files:(Driver.read_config_changed_files ()) + Driver.register_perf_stats_report PerfStats.TotalBackend ; + Driver.analyze_and_report Analyze ~changed_files:(Driver.read_config_changed_files ()) ; + PerfStats.get_reporter PerfStats.TotalBackend () | Report -> InferPrint.main ~report_json:None | ReportDiff -> diff --git a/infer/src/integration/Diff.ml b/infer/src/integration/Diff.ml index 2411ec0db..106836ab5 100644 --- a/infer/src/integration/Diff.ml +++ b/infer/src/integration/Diff.ml @@ -63,8 +63,12 @@ let gen_previous_driver_mode script = let diff driver_mode = Driver.run_prologue driver_mode ; let changed_files = Driver.read_config_changed_files () in + Driver.register_perf_stats_report PerfStats.TotalFrontend ; Driver.capture driver_mode ~changed_files ; + PerfStats.get_reporter PerfStats.TotalFrontend () ; + Driver.register_perf_stats_report PerfStats.TotalBackend ; Driver.analyze_and_report ~suppress_console_report:true driver_mode ~changed_files ; + PerfStats.get_reporter PerfStats.TotalBackend () ; let current_report = Some (save_report Current) in (* Some files in the current checkout may be deleted in the old checkout. If we kept the results of the previous capture and analysis around, we would report issues on these files again in the previous checkout, which is wrong. Do not do anything too smart for now and just delete all results from the analysis of the current checkout. *) ResultsDir.delete_capture_and_analysis_data () ; @@ -75,8 +79,12 @@ let diff driver_mode = Option.value_map ~default:driver_mode ~f:gen_previous_driver_mode Config.gen_previous_build_command_script in + Driver.register_perf_stats_report PerfStats.TotalFrontend ; Driver.capture previous_driver_mode ~changed_files ; + PerfStats.get_reporter PerfStats.TotalFrontend () ; + Driver.register_perf_stats_report PerfStats.TotalBackend ; Driver.analyze_and_report ~suppress_console_report:true previous_driver_mode ~changed_files ; + PerfStats.get_reporter PerfStats.TotalBackend () ; checkout Current ; let previous_report = Some (save_report Previous) in (* compute differential *) diff --git a/infer/src/integration/Driver.ml b/infer/src/integration/Driver.ml index 2e2df502a..40650e473 100644 --- a/infer/src/integration/Driver.ml +++ b/infer/src/integration/Driver.ml @@ -528,6 +528,11 @@ let mode_from_command_line = mode_of_build_command (List.rev Config.rest) ) +let register_perf_stats_report stats_type = + let rtime_span, initial_times = (Mtime_clock.counter (), Unix.times ()) in + PerfStats.register_report (PerfStats.Time (rtime_span, initial_times)) stats_type + + let run_prologue mode = if CLOpt.is_originator then ( L.environment_info "%a@\n" Config.pp_version () ; diff --git a/infer/src/integration/Driver.mli b/infer/src/integration/Driver.mli index 91b29b05c..354b0b0ff 100644 --- a/infer/src/integration/Driver.mli +++ b/infer/src/integration/Driver.mli @@ -34,6 +34,8 @@ val mode_from_command_line : mode Lazy.t val mode_of_build_command : string list -> mode (** driver mode computed from the build command alone, eg [["buck"; "build"; ...]] gives [PythonCapture (BBuck, ["buck"; "build"; ...])] *) +val register_perf_stats_report : PerfStats.stats_type -> unit + val run_prologue : mode -> unit (** prepare the environment for running the given mode *)