diff --git a/infer/bin/inferlib.py b/infer/bin/inferlib.py index d9585f40d..afd891cdc 100644 --- a/infer/bin/inferlib.py +++ b/infer/bin/inferlib.py @@ -215,7 +215,7 @@ def create_results_dir(results_dir): def clean(infer_out, annotations_out): - + directories = ['multicore', 'classnames', 'sources', jwlib.FILELISTS] extensions = ['.cfg', '.cg'] @@ -652,30 +652,32 @@ class Infer: def save_stats(self): """Print timing information to infer_out/stats.json""" - stats_path = os.path.join(self.args.infer_out, utils.STATS_FILENAME) + proc_stats_path = os.path.join( + self.args.infer_out, + utils.PROC_STATS_FILENAME) + + # capture and compile mode do not create proc_stats.json + if os.path.isfile(proc_stats_path): + with open(proc_stats_path, 'r') as proc_stats_file: + proc_stats = json.load(proc_stats_file) + self.stats['int'].update(proc_stats) + + self.stats['float'] = { + 'capture_time': self.timing.get('capture', 0.0), + 'makefile_generation_time': self.timing.get( + 'makefile_generation', 0.0), + 'analysis_time': self.timing.get('analysis', 0.0), + 'reporting_time': self.timing.get('reporting', 0.0), + } + self.stats['normal'] = { + 'analyzer': self.args.analyzer, + 'infer_version': utils.infer_version() + } - # capture and compile mode do not create stats.json - if not os.path.isfile(stats_path): - with open(stats_path, 'w') as stats_file: - json.dump(self.stats, stats_file, indent=2) - - with open(stats_path, 'r+') as stats_file: - file_stats = json.load(stats_file) - self.stats['int'].update(file_stats) - self.stats['float'] = { - 'capture_time': self.timing.get('capture', 0.0), - 'makefile_generation_time': self.timing.get( - 'makefile_generation', 0.0), - 'analysis_time': self.timing.get('analysis', 0.0), - 'reporting_time': self.timing.get('reporting', 0.0), - } - self.stats['normal'] = { - 'analyzer': self.args.analyzer, - 'infer_version': utils.infer_version() - } - stats_file.seek(0) + stats_path = os.path.join(self.args.infer_out, utils.STATS_FILENAME) + with open(stats_path, 'w') as stats_file: json.dump(self.stats, stats_file, indent=2) - stats_file.truncate() + def close(self): if self.args.analyzer != COMPILE: diff --git a/infer/bin/utils.py b/infer/bin/utils.py index d285647d9..aaee6c816 100644 --- a/infer/bin/utils.py +++ b/infer/bin/utils.py @@ -36,6 +36,7 @@ ANNOT_PROCESSOR_JAR = os.path.join( DEFAULT_INFER_OUT = os.path.join(os.getcwd(), 'infer-out') CSV_PERF_FILENAME = 'performances.csv' STATS_FILENAME = 'stats.json' +PROC_STATS_FILENAME = 'proc_stats.json' CSV_REPORT_FILENAME = 'report.csv' JSON_REPORT_FILENAME = 'report.json' diff --git a/infer/src/backend/config.ml b/infer/src/backend/config.ml index 998fc70b9..519e08852 100644 --- a/infer/src/backend/config.ml +++ b/infer/src/backend/config.ml @@ -36,7 +36,7 @@ let default_in_zip_results_dir = "infer" let default_buck_out = "buck-out" -let stats_filename = "stats.json" +let proc_stats_filename = "proc_stats.json" let global_tenv_filename = "global.tenv" diff --git a/infer/src/backend/inferanalyze.ml b/infer/src/backend/inferanalyze.ml index a4683db24..e6534d68d 100644 --- a/infer/src/backend/inferanalyze.ml +++ b/infer/src/backend/inferanalyze.ml @@ -369,7 +369,7 @@ let output_json_file_stats num_files num_procs num_lines = ("procedures", `Int num_procs); ("lines", `Int num_lines) ] in (* write stats file to disk, intentionally overwriting old file if it already exists *) - let f = open_out (Filename.concat !Config.results_dir Config.stats_filename) in + let f = open_out (Filename.concat !Config.results_dir Config.proc_stats_filename) in Yojson.Basic.pretty_to_channel f file_stats (** create clusters of minimal size in the dependence order, with recursive parts grouped together *)