From 1d2d6b7976f3367f070f47cab78210593b73e999 Mon Sep 17 00:00:00 2001 From: Jeremy Dubreil Date: Mon, 12 Feb 2018 09:34:43 -0800 Subject: [PATCH] [infer][report] fix performance issue when logging events Reviewed By: dulmarod, jvillard Differential Revision: D6960795 fbshipit-source-id: c10eca6 --- infer/src/backend/InferPrint.ml | 3 ++- infer/src/base/EventLogger.ml | 8 -------- infer/src/base/EventLogger.mli | 2 -- 3 files changed, 2 insertions(+), 11 deletions(-) diff --git a/infer/src/backend/InferPrint.ml b/infer/src/backend/InferPrint.ml index a498f0bf5..c1f0e7957 100644 --- a/infer/src/backend/InferPrint.ml +++ b/infer/src/backend/InferPrint.ml @@ -536,6 +536,7 @@ module Stats = struct ; symops= summary.stats.symops } :: stats.events_to_log + let num_files stats = Hashtbl.length stats.files let pp fmt stats = @@ -1031,7 +1032,7 @@ let finalize_and_close_files format_list_by_kind (stats: Stats.t) = let outfile = get_outfile outfile_opt in IssuesJson.pp_json_close outfile.fmt () | Logs, Stats -> - EventLogger.log_multiple stats.events_to_log + List.iter ~f:EventLogger.log stats.events_to_log | Csv, (Issues | Procs | Calls | Summary) | Logs, (Issues | Procs | Calls | Summary) | Json, (Procs | Stats | Calls | Summary) diff --git a/infer/src/base/EventLogger.ml b/infer/src/base/EventLogger.ml index dbae7c062..c062c78ec 100644 --- a/infer/src/base/EventLogger.ml +++ b/infer/src/base/EventLogger.ml @@ -220,12 +220,4 @@ let prepare = IO.prepare let log event = IO.write "%s\n" (create_row event) -let log_multiple events = - let rows = List.map ~f:create_row events in - let combinedJson = - List.fold_right rows ~init:"" ~f:(fun row combined -> combined ^ row ^ "\n") - in - IO.write "%s" combinedJson - - let dump = IO.dump diff --git a/infer/src/base/EventLogger.mli b/infer/src/base/EventLogger.mli index 891a6f633..288364e31 100644 --- a/infer/src/base/EventLogger.mli +++ b/infer/src/base/EventLogger.mli @@ -45,6 +45,4 @@ val prepare : unit -> unit val log : event -> unit -val log_multiple : event list -> unit - val dump : unit -> unit