[Infer][Perf] Deduplication of identical perf reports

Reviewed By: ddino

Differential Revision: D12941486

fbshipit-source-id: 9fb4be532
master
Martino Luca 6 years ago committed by Facebook Github Bot
parent 9a4416f7d4
commit ef2cfa7b40

@ -128,12 +128,12 @@ let to_map key_func report =
~init:String.Map.empty report ~init:String.Map.empty report
let issue_of_cost (cost_info, cost_polynomial) ~delta ~prev_cost ~curr_cost = let issue_of_cost cost_info ~delta ~prev_cost ~curr_cost =
let file = cost_info.Jsonbug_t.loc.file in let file = cost_info.Jsonbug_t.loc.file in
let source_file = SourceFile.create ~warn_on_error:false file in let source_file = SourceFile.create ~warn_on_error:false file in
let issue_type = let issue_type =
if CostDomain.BasicCost.is_top cost_polynomial then IssueType.infinite_execution_time_call if CostDomain.BasicCost.is_top curr_cost then IssueType.infinite_execution_time_call
else if CostDomain.BasicCost.is_zero cost_polynomial 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
let qualifier = let qualifier =
@ -146,7 +146,7 @@ let issue_of_cost (cost_info, cost_polynomial) ~delta ~prev_cost ~curr_cost =
in in
Format.asprintf "Max degree %a from %a to %a. Cost is %a (degree is %a)" pp_delta delta Format.asprintf "Max degree %a from %a to %a. Cost is %a (degree is %a)" pp_delta delta
CostDomain.BasicCost.pp_degree prev_cost CostDomain.BasicCost.pp_degree curr_cost CostDomain.BasicCost.pp_degree prev_cost CostDomain.BasicCost.pp_degree curr_cost
CostDomain.BasicCost.pp cost_polynomial CostDomain.BasicCost.pp_degree cost_polynomial CostDomain.BasicCost.pp curr_cost CostDomain.BasicCost.pp_degree curr_cost
in in
let line = cost_info.Jsonbug_t.loc.lnum in let line = cost_info.Jsonbug_t.loc.lnum in
let column = cost_info.Jsonbug_t.loc.cnum in let column = cost_info.Jsonbug_t.loc.cnum in
@ -192,25 +192,23 @@ let of_costs ~(current_costs : Jsonbug_t.costs_report) ~(previous_costs : Jsonbu
List.max_elt l ~compare:(fun (_, c1) (_, c2) -> List.max_elt l ~compare:(fun (_, c1) (_, c2) ->
CostDomain.BasicCost.compare_by_degree c1 c2 ) CostDomain.BasicCost.compare_by_degree c1 c2 )
in in
Option.value_exn max |> snd Option.value_exn max
in in
let 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
if cmp > 0 then if cmp > 0 then
(* introduced *) (* introduced *)
let left' = let left' =
List.rev_map_append let issue = issue_of_cost curr_cost_info ~delta:`Increased ~prev_cost ~curr_cost in
~f:(fun c -> issue_of_cost c ~delta:`Increased ~prev_cost ~curr_cost) issue :: left
current 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' =
List.rev_map_append let issue = issue_of_cost curr_cost_info ~delta:`Decreased ~prev_cost ~curr_cost in
~f:(fun c -> issue_of_cost c ~delta:`Decreased ~prev_cost ~curr_cost) issue :: right
current right
in in
(left, both, right') (left, both, right')
else else

Loading…
Cancel
Save