diff --git a/infer/src/backend/PerfStats.ml b/infer/src/backend/PerfStats.ml index e756d8267..2ef91d32a 100644 --- a/infer/src/backend/PerfStats.ml +++ b/infer/src/backend/PerfStats.ml @@ -13,25 +13,28 @@ open! Utils let register_report_at_exit file = Pervasives.at_exit (fun () -> - let gc_stats = Gc.quick_stat () in - let exit_timeofday = Unix.gettimeofday () in - let exit_times = Unix.times () in - let stats = - `Assoc [ - ("rtime", `Float (exit_timeofday -. initial_timeofday)) ; - ("utime", `Float (exit_times.tms_utime -. initial_times.tms_utime)) ; - ("stime", `Float (exit_times.tms_stime -. initial_times.tms_stime)) ; - ("cutime", `Float (exit_times.tms_cutime -. initial_times.tms_cutime)) ; - ("cstime", `Float (exit_times.tms_cstime -. initial_times.tms_cstime)) ; - ("minor_words", `Float gc_stats.minor_words) ; - ("promoted_words", `Float gc_stats.promoted_words) ; - ("major_words", `Float gc_stats.major_words) ; - ("minor_collections", `Int gc_stats.minor_collections) ; - ("major_collections", `Int gc_stats.major_collections) ; - ("compactions", `Int gc_stats.compactions) ; - ("top_heap_words", `Int gc_stats.top_heap_words) ; - ] in - let stats_oc = open_out file in - Yojson.Basic.pretty_to_channel stats_oc stats ; - close_out stats_oc + try + let gc_stats = Gc.quick_stat () in + let exit_timeofday = Unix.gettimeofday () in + let exit_times = Unix.times () in + let stats = + `Assoc [ + ("rtime", `Float (exit_timeofday -. initial_timeofday)) ; + ("utime", `Float (exit_times.tms_utime -. initial_times.tms_utime)) ; + ("stime", `Float (exit_times.tms_stime -. initial_times.tms_stime)) ; + ("cutime", `Float (exit_times.tms_cutime -. initial_times.tms_cutime)) ; + ("cstime", `Float (exit_times.tms_cstime -. initial_times.tms_cstime)) ; + ("minor_words", `Float gc_stats.minor_words) ; + ("promoted_words", `Float gc_stats.promoted_words) ; + ("major_words", `Float gc_stats.major_words) ; + ("minor_collections", `Int gc_stats.minor_collections) ; + ("major_collections", `Int gc_stats.major_collections) ; + ("compactions", `Int gc_stats.compactions) ; + ("top_heap_words", `Int gc_stats.top_heap_words) ; + ] in + let stats_oc = open_out file in + Yojson.Basic.pretty_to_channel stats_oc stats ; + close_out stats_oc + with _ -> + Format.fprintf Format.std_formatter "Info: failed to write stats to %s@." file ) diff --git a/infer/src/backend/inferanalyze.ml b/infer/src/backend/inferanalyze.ml index 4479c9676..2f9802db4 100644 --- a/infer/src/backend/inferanalyze.ml +++ b/infer/src/backend/inferanalyze.ml @@ -355,7 +355,7 @@ let process_cluster_cmdline fname = let register_perf_stats_report () = let stats_dir = Filename.concat !Config.results_dir Config.backend_stats_dir_name in - let cluster = match !cluster_cmdline with Some cl -> "_" ^ cl | None -> "" in + let cluster = match !cluster_cmdline with Some cl -> "_" ^ (Filename.basename cl) | None -> "" in let stats_file = Filename.concat stats_dir (Config.perf_stats_prefix ^ cluster ^ ".json") in DB.create_dir !Config.results_dir ; DB.create_dir stats_dir ;