fix a bug preventing to run the capture only with Buck

Summary: @​public
There was an inconsistency with the type of `stats.json` created by `inferlib.py` and InferAnalyze. This diff cleans up the thing and uses two different files to saves the statistics to clarify what gets created by the analysis, i.e. `proc_stats.json` and what gets created all the time `stats.json`.

Reviewed By: @sblackshear

Differential Revision: D2500517
master
jrm 9 years ago committed by facebook-github-bot-1
parent d6b1d422fd
commit 5e41fc7a54

@ -215,7 +215,7 @@ def create_results_dir(results_dir):
def clean(infer_out, annotations_out): def clean(infer_out, annotations_out):
directories = ['multicore', 'classnames', 'sources', jwlib.FILELISTS] directories = ['multicore', 'classnames', 'sources', jwlib.FILELISTS]
extensions = ['.cfg', '.cg'] extensions = ['.cfg', '.cg']
@ -652,30 +652,32 @@ class Infer:
def save_stats(self): def save_stats(self):
"""Print timing information to infer_out/stats.json""" """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 stats_path = os.path.join(self.args.infer_out, utils.STATS_FILENAME)
if not os.path.isfile(stats_path): with open(stats_path, 'w') as stats_file:
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)
json.dump(self.stats, stats_file, indent=2) json.dump(self.stats, stats_file, indent=2)
stats_file.truncate()
def close(self): def close(self):
if self.args.analyzer != COMPILE: if self.args.analyzer != COMPILE:

@ -36,6 +36,7 @@ ANNOT_PROCESSOR_JAR = os.path.join(
DEFAULT_INFER_OUT = os.path.join(os.getcwd(), 'infer-out') DEFAULT_INFER_OUT = os.path.join(os.getcwd(), 'infer-out')
CSV_PERF_FILENAME = 'performances.csv' CSV_PERF_FILENAME = 'performances.csv'
STATS_FILENAME = 'stats.json' STATS_FILENAME = 'stats.json'
PROC_STATS_FILENAME = 'proc_stats.json'
CSV_REPORT_FILENAME = 'report.csv' CSV_REPORT_FILENAME = 'report.csv'
JSON_REPORT_FILENAME = 'report.json' JSON_REPORT_FILENAME = 'report.json'

@ -36,7 +36,7 @@ let default_in_zip_results_dir = "infer"
let default_buck_out = "buck-out" let default_buck_out = "buck-out"
let stats_filename = "stats.json" let proc_stats_filename = "proc_stats.json"
let global_tenv_filename = "global.tenv" let global_tenv_filename = "global.tenv"

@ -369,7 +369,7 @@ let output_json_file_stats num_files num_procs num_lines =
("procedures", `Int num_procs); ("procedures", `Int num_procs);
("lines", `Int num_lines) ] in ("lines", `Int num_lines) ] in
(* write stats file to disk, intentionally overwriting old file if it already exists *) (* 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 Yojson.Basic.pretty_to_channel f file_stats
(** create clusters of minimal size in the dependence order, with recursive parts grouped together *) (** create clusters of minimal size in the dependence order, with recursive parts grouped together *)

Loading…
Cancel
Save