[Perf] Embed filtering for costs reports

Reviewed By: mbouaziz

Differential Revision: D13103020

fbshipit-source-id: 641e549ee
master
Martino Luca 6 years ago committed by Facebook Github Bot
parent 29631b7358
commit 6d12d67613

@ -136,6 +136,7 @@ let issue_of_cost cost_info ~delta ~prev_cost ~curr_cost =
else if CostDomain.BasicCost.is_zero curr_cost then IssueType.zero_execution_time_call
else IssueType.performance_variation
in
if (not Config.filtering) || issue_type.IssueType.enabled then
let qualifier =
let pp_delta fmt delta =
match delta with
@ -164,6 +165,7 @@ let issue_of_cost cost_info ~delta ~prev_cost ~curr_cost =
[Errlog.make_trace_element 0 {Location.line; col= column; file= source_file} "" []]
in
let severity = Exceptions.Warning in
Some
{ Jsonbug_j.bug_type= issue_type.IssueType.unique_id
; qualifier
; severity= Exceptions.severity_string severity
@ -171,7 +173,7 @@ let issue_of_cost cost_info ~delta ~prev_cost ~curr_cost =
; line
; column
; procedure= cost_info.Jsonbug_t.procedure_id
; procedure_start_line= 0
; procedure_start_line= line
; file
; bug_trace= InferPrint.loc_trace_to_jsonbug_record trace severity
; key= ""
@ -186,6 +188,7 @@ let issue_of_cost cost_info ~delta ~prev_cost ~curr_cost =
; censored_reason= InferPrint.censored_reason issue_type source_file
; access= None
; extras= None }
else None
(** Differential of cost reports, based on degree variations.
@ -207,18 +210,18 @@ let of_costs ~(current_costs : Jsonbug_t.costs_report) ~(previous_costs : Jsonbu
let curr_cost_info, curr_cost = max_degree_polynomial current in
let _, prev_cost = max_degree_polynomial previous in
let cmp = CostDomain.BasicCost.compare_by_degree curr_cost prev_cost in
let concat_opt l v = match v with Some v' -> v' :: l | None -> l in
if cmp > 0 then
(* introduced *)
let left' =
let issue = issue_of_cost curr_cost_info ~delta:`Increased ~prev_cost ~curr_cost in
issue :: left
issue_of_cost curr_cost_info ~delta:`Increased ~prev_cost ~curr_cost |> concat_opt left
in
(left', both, right)
else if cmp < 0 then
(* fixed *)
let right' =
let issue = issue_of_cost curr_cost_info ~delta:`Decreased ~prev_cost ~curr_cost in
issue :: right
issue_of_cost curr_cost_info ~delta:`Decreased ~prev_cost ~curr_cost
|> concat_opt right
in
(left, both, right')
else

@ -240,6 +240,14 @@ type json_issue_printer_typ =
; err_key: Errlog.err_key
; err_data: Errlog.err_data }
let procedure_id_of_procname proc_name =
match Typ.Procname.get_language proc_name with
| Language.Java ->
Typ.Procname.to_unique_id proc_name
| _ ->
Typ.Procname.to_string proc_name
module JsonIssuePrinter = MakeJsonListPrinter (struct
type elt = json_issue_printer_typ
@ -288,13 +296,6 @@ module JsonIssuePrinter = MakeJsonListPrinter (struct
Format.sprintf "%s@\n%s" base_qualifier potential_exception_message
else base_qualifier
in
let procedure =
match Typ.Procname.get_language proc_name with
| Language.Java ->
Typ.Procname.to_unique_id proc_name
| _ ->
Typ.Procname.to_string proc_name
in
let bug =
{ Jsonbug_j.bug_type
; qualifier
@ -302,7 +303,7 @@ module JsonIssuePrinter = MakeJsonListPrinter (struct
; visibility
; line= err_data.loc.Location.line
; column= err_data.loc.Location.col
; procedure
; procedure= procedure_id_of_procname proc_name
; procedure_start_line
; file
; bug_trace= loc_trace_to_jsonbug_record err_data.loc_trace err_key.severity
@ -353,7 +354,7 @@ module JsonCostsPrinter = MakeJsonListPrinter (struct
let file = SourceFile.to_rel_path loc.Location.file in
{ Jsonbug_t.hash= compute_hash ~severity:"" ~bug_type:"" ~proc_name ~file ~qualifier:""
; loc= {file; lnum= loc.Location.line; cnum= loc.Location.col; enum= -1}
; procedure_id= Typ.Procname.to_string proc_name
; procedure_id= procedure_id_of_procname proc_name
; polynomial= CostDomain.BasicCost.encode post
; hum }
in

@ -16,9 +16,9 @@ $(CURRENT_REPORT) $(PREVIOUS_REPORT): $(JAVA_DEPS)
$(CURRENT_REPORT):
$(QUIET)$(COPY) src/DiffExample.java.current src/DiffExample.java
$(QUIET)$(call silent_on_success,Testing Differential skips anon class renamings: current,\
$(INFER_BIN) --cost-only -o $(CURRENT_DIR) -- $(JAVAC) src/*.java)
$(INFER_BIN) --enable-issue-type INFINITE_EXECUTION_TIME_CALL --cost-only -o $(CURRENT_DIR) -- $(JAVAC) src/*.java)
$(PREVIOUS_REPORT):
$(QUIET)$(COPY) src/DiffExample.java.previous src/DiffExample.java
$(QUIET)$(call silent_on_success,Testing Differential skips anon class renamings: previous,\
$(INFER_BIN) --cost-only -o $(PREVIOUS_DIR) -- $(JAVAC) src/*.java)
$(INFER_BIN) --enable-issue-type INFINITE_EXECUTION_TIME_CALL --cost-only -o $(PREVIOUS_DIR) -- $(JAVAC) src/*.java)

@ -1 +1 @@
PERFORMANCE_VARIATION, no_bucket, src/DiffExample.java, void DiffExample.f2(int), 27
PERFORMANCE_VARIATION, no_bucket, src/DiffExample.java, DiffExample.f2(int):void, 0

@ -1,2 +1,2 @@
PERFORMANCE_VARIATION, no_bucket, src/DiffExample.java, int DiffExample.f4(int), 39
INFINITE_EXECUTION_TIME_CALL, no_bucket, src/DiffExample.java, void DiffExample.f1(int), 19
INFINITE_EXECUTION_TIME_CALL, no_bucket, src/DiffExample.java, DiffExample.f1(int):void, 0
PERFORMANCE_VARIATION, no_bucket, src/DiffExample.java, DiffExample.f4(int):int, 0

Loading…
Cancel
Save