From 2e8fc680806ef1f52776a37dab003a1a211808b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ezgi=20=C3=87i=C3=A7ek?= Date: Tue, 21 Jan 2020 03:59:02 -0800 Subject: [PATCH] [cost] Add mli file for CostDomain Reviewed By: jvillard Differential Revision: D19471030 fbshipit-source-id: bdf4876b8 --- infer/src/checkers/costDomain.ml | 4 --- infer/src/checkers/costDomain.mli | 54 +++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 infer/src/checkers/costDomain.mli diff --git a/infer/src/checkers/costDomain.ml b/infer/src/checkers/costDomain.ml index ca85cecc0..fc4c96d03 100644 --- a/infer/src/checkers/costDomain.ml +++ b/infer/src/checkers/costDomain.ml @@ -52,7 +52,6 @@ let get_operation_cost cost_record = get_cost_kind CostKind.OperationCost cost_r let map ~f cost_record = VariantCostMap.map f cost_record -(* Map representing cost record {OperationCost:0; AllocationCost:0; IOCost:0} *) let zero_record = VariantCostMap.empty let mult_by_scalar cost_record scalar = map cost_record ~f:(BasicCost.mult scalar) @@ -63,12 +62,9 @@ let plus cost_record1 cost_record2 = cost_record1 cost_record2 -(* Map representing cost record {OperationCost:1; AllocationCost:0; IOCost:0} *) let unit_cost_atomic_operation = VariantCostMap.increment CostKind.OperationCost zero_record -(* Map representing cost record {OperationCost:0; AllocationCost:1; IOCost:0} *) let unit_cost_allocation = VariantCostMap.increment CostKind.AllocationCost zero_record -(* Map representing cost record {OperationCost:operation_cost; AllocationCost:0; IOCost:0} *) let of_operation_cost operation_cost = VariantCostMap.increase_by CostKind.OperationCost operation_cost zero_record diff --git a/infer/src/checkers/costDomain.mli b/infer/src/checkers/costDomain.mli new file mode 100644 index 000000000..a96058c3d --- /dev/null +++ b/infer/src/checkers/costDomain.mli @@ -0,0 +1,54 @@ +(* + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + *) + +open! IStd +module F = Format + +module BasicCost : sig + include + module type of Polynomials.NonNegativePolynomial + with type t = Polynomials.NonNegativePolynomial.t + + val version : int + (** version used to consistently compare at infer-reportdiff phase *) +end + +module VariantCostMap : sig + type t = BasicCost.t CostIssues.CostKindMap.t + + val pp : F.formatter -> t -> unit +end + +type t = VariantCostMap.t + +type summary = {post: t; is_on_ui_thread: bool} + +val pp_summary : F.formatter -> summary -> unit + +val get_cost_kind : CostKind.t -> t -> BasicCost.t + +val get_operation_cost : t -> BasicCost.t + +val map : f:(BasicCost.t -> BasicCost.t) -> t -> t + +val zero_record : t +(** Map representing cost record {OperationCost:0; AllocationCost:0; IOCost:0} *) + +val mult_by_scalar : t -> BasicCost.t -> t +(** Map where each element is multiplied by a cost *) + +val plus : t -> t -> t +(** Union of two maps where common costs are added together *) + +val unit_cost_atomic_operation : t +(** Map representing cost record {OperationCost:1; AllocationCost:0; IOCost:0} *) + +val unit_cost_allocation : t +(** Map representing cost record {OperationCost:0; AllocationCost:1; IOCost:0} *) + +val of_operation_cost : BasicCost.t -> t +(** Map representing cost record {OperationCost:operation_cost; AllocationCost:0; IOCost:0} *)