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

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

@ -16,9 +16,9 @@ $(CURRENT_REPORT) $(PREVIOUS_REPORT): $(JAVA_DEPS)
$(CURRENT_REPORT): $(CURRENT_REPORT):
$(QUIET)$(COPY) src/DiffExample.java.current src/DiffExample.java $(QUIET)$(COPY) src/DiffExample.java.current src/DiffExample.java
$(QUIET)$(call silent_on_success,Testing Differential skips anon class renamings: current,\ $(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): $(PREVIOUS_REPORT):
$(QUIET)$(COPY) src/DiffExample.java.previous src/DiffExample.java $(QUIET)$(COPY) src/DiffExample.java.previous src/DiffExample.java
$(QUIET)$(call silent_on_success,Testing Differential skips anon class renamings: previous,\ $(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, DiffExample.f1(int):void, 0
INFINITE_EXECUTION_TIME_CALL, no_bucket, src/DiffExample.java, void DiffExample.f1(int), 19 PERFORMANCE_VARIATION, no_bucket, src/DiffExample.java, DiffExample.f4(int):int, 0

Loading…
Cancel
Save