diff --git a/infer/src/backend/Differential.ml b/infer/src/backend/Differential.ml index e35d3aad3..df4110c10 100644 --- a/infer/src/backend/Differential.ml +++ b/infer/src/backend/Differential.ml @@ -193,7 +193,7 @@ module CostItem = struct CostDomain.BasicCost.pp_degree ~only_bigO fmt degree_with_term - let pp_cost_msg fmt ({polynomial} as curr_item) = + let pp_cost_msg fmt ({cost_item= {procedure_name}; polynomial} as curr_item) = let pp_cost fmt = match polynomial with | None -> @@ -201,7 +201,8 @@ module CostItem = struct | Some p -> CostDomain.BasicCost.pp_hum fmt p in - Format.fprintf fmt "Cost is %t (degree is %a)" pp_cost (pp_degree ~only_bigO:false) curr_item + Format.fprintf fmt "Cost of %s is %t (degree is %a)" procedure_name pp_cost + (pp_degree ~only_bigO:false) curr_item end let issue_of_cost kind CostIssues.{complexity_increase_issue; unreachable_issue; infinite_issue} diff --git a/infer/tests/build_systems/differential_of_costs_report/fixed.exp b/infer/tests/build_systems/differential_of_costs_report/fixed.exp index 53f0874d8..1f51121ec 100644 --- a/infer/tests/build_systems/differential_of_costs_report/fixed.exp +++ b/infer/tests/build_systems/differential_of_costs_report/fixed.exp @@ -1,3 +1,3 @@ -EXECUTION_TIME_COMPLEXITY_INCREASE, no_bucket, src/DiffExample.java, DiffExample.f6(java.util.ArrayList):void, 0, [Updated Cost is 5 + list.length × log(list.length) (degree is 1 + 1⋅log),{list.length},call to void DiffExample.f5(ArrayList),Modeled call to Collections.sort,{list.length},call to void DiffExample.f5(ArrayList),Modeled call to Collections.sort] -EXECUTION_TIME_COMPLEXITY_INCREASE_COLD_START, no_bucket, src/DiffExampleColdStart.java, DiffExampleColdStart.f6(java.util.ArrayList):void, 0, [Updated Cost is 5 + list.length × log(list.length) (degree is 1 + 1⋅log),{list.length},call to void DiffExampleColdStart.f5(ArrayList),Modeled call to Collections.sort,{list.length},call to void DiffExampleColdStart.f5(ArrayList),Modeled call to Collections.sort] -EXECUTION_TIME_COMPLEXITY_INCREASE_UI_THREAD, no_bucket, src/DiffExampleUIThread.java, DiffExampleUIThread.f1(int):void, 0, [Updated Cost is 3 (degree is 0)] +EXECUTION_TIME_COMPLEXITY_INCREASE, no_bucket, src/DiffExample.java, DiffExample.f6(java.util.ArrayList):void, 0, [Updated Cost of f6 is 5 + list.length × log(list.length) (degree is 1 + 1⋅log),{list.length},call to void DiffExample.f5(ArrayList),Modeled call to Collections.sort,{list.length},call to void DiffExample.f5(ArrayList),Modeled call to Collections.sort] +EXECUTION_TIME_COMPLEXITY_INCREASE_COLD_START, no_bucket, src/DiffExampleColdStart.java, DiffExampleColdStart.f6(java.util.ArrayList):void, 0, [Updated Cost of f6 is 5 + list.length × log(list.length) (degree is 1 + 1⋅log),{list.length},call to void DiffExampleColdStart.f5(ArrayList),Modeled call to Collections.sort,{list.length},call to void DiffExampleColdStart.f5(ArrayList),Modeled call to Collections.sort] +EXECUTION_TIME_COMPLEXITY_INCREASE_UI_THREAD, no_bucket, src/DiffExampleUIThread.java, DiffExampleUIThread.f1(int):void, 0, [Updated Cost of f1 is 3 (degree is 0)] diff --git a/infer/tests/build_systems/differential_of_costs_report/introduced.exp b/infer/tests/build_systems/differential_of_costs_report/introduced.exp index ba84d5791..2169f4984 100644 --- a/infer/tests/build_systems/differential_of_costs_report/introduced.exp +++ b/infer/tests/build_systems/differential_of_costs_report/introduced.exp @@ -1,8 +1,8 @@ -EXECUTION_TIME_COMPLEXITY_INCREASE, no_bucket, src/DiffExample.java, DiffExample$1.toString():java.lang.String, 0, [Updated Cost is 16 + 13 ⋅ this.this$0.z + 5 ⋅ this.this$0.z × this.this$0.z (degree is 2),{this.this$0.z},call to void DiffExample.f8(int),call to int DiffExample.f4(int),Loop at line 57,{this.this$0.z},call to void DiffExample.f8(int),Loop at line 79] +EXECUTION_TIME_COMPLEXITY_INCREASE, no_bucket, src/DiffExample.java, DiffExample$1.toString():java.lang.String, 0, [Updated Cost of toString is 16 + 13 ⋅ this.this$0.z + 5 ⋅ this.this$0.z × this.this$0.z (degree is 2),{this.this$0.z},call to void DiffExample.f8(int),call to int DiffExample.f4(int),Loop at line 57,{this.this$0.z},call to void DiffExample.f8(int),Loop at line 79] INFINITE_EXECUTION_TIME, no_bucket, src/DiffExample.java, DiffExample.f1(int):void, 0, [Unbounded loop,Loop at line 38] -EXECUTION_TIME_COMPLEXITY_INCREASE, no_bucket, src/DiffExample.java, DiffExample.f4(int):int, 0, [Updated Cost is 6 + 5 ⋅ k (degree is 1),{k},Loop at line 57] -EXECUTION_TIME_COMPLEXITY_INCREASE, no_bucket, src/DiffExample.java, DiffExample.f5(java.util.ArrayList):void, 0, [Updated Cost is 2 + list.length × log(list.length) (degree is 1 + 1⋅log),{list.length},Modeled call to Collections.sort,{list.length},Modeled call to Collections.sort] +EXECUTION_TIME_COMPLEXITY_INCREASE, no_bucket, src/DiffExample.java, DiffExample.f4(int):int, 0, [Updated Cost of f4 is 6 + 5 ⋅ k (degree is 1),{k},Loop at line 57] +EXECUTION_TIME_COMPLEXITY_INCREASE, no_bucket, src/DiffExample.java, DiffExample.f5(java.util.ArrayList):void, 0, [Updated Cost of f5 is 2 + list.length × log(list.length) (degree is 1 + 1⋅log),{list.length},Modeled call to Collections.sort,{list.length},Modeled call to Collections.sort] INFINITE_EXECUTION_TIME, no_bucket, src/DiffExampleColdStart.java, DiffExampleColdStart.f1(int):void, 0, [Unbounded loop,Loop at line 26] -EXECUTION_TIME_COMPLEXITY_INCREASE_COLD_START, no_bucket, src/DiffExampleColdStart.java, DiffExampleColdStart.f4(int):int, 0, [Updated Cost is 6 + 7 ⋅ k (degree is 1),{k},Loop at line 45] -EXECUTION_TIME_COMPLEXITY_INCREASE, no_bucket, src/DiffExampleColdStart.java, DiffExampleColdStart.f5(java.util.ArrayList):void, 0, [Updated Cost is 2 + list.length × log(list.length) (degree is 1 + 1⋅log),{list.length},Modeled call to Collections.sort,{list.length},Modeled call to Collections.sort] -EXECUTION_TIME_COMPLEXITY_INCREASE_UI_THREAD, no_bucket, src/DiffExampleUIThread.java, DiffExampleUIThread.f2(int):void, 0, [Updated Cost is 5 + 5 ⋅ x (degree is 1),{x},Loop at line 27] +EXECUTION_TIME_COMPLEXITY_INCREASE_COLD_START, no_bucket, src/DiffExampleColdStart.java, DiffExampleColdStart.f4(int):int, 0, [Updated Cost of f4 is 6 + 7 ⋅ k (degree is 1),{k},Loop at line 45] +EXECUTION_TIME_COMPLEXITY_INCREASE, no_bucket, src/DiffExampleColdStart.java, DiffExampleColdStart.f5(java.util.ArrayList):void, 0, [Updated Cost of f5 is 2 + list.length × log(list.length) (degree is 1 + 1⋅log),{list.length},Modeled call to Collections.sort,{list.length},Modeled call to Collections.sort] +EXECUTION_TIME_COMPLEXITY_INCREASE_UI_THREAD, no_bucket, src/DiffExampleUIThread.java, DiffExampleUIThread.f2(int):void, 0, [Updated Cost of f2 is 5 + 5 ⋅ x (degree is 1),{x},Loop at line 27]