[cost] Add mli file for CostDomain

Reviewed By: jvillard

Differential Revision: D19471030

fbshipit-source-id: bdf4876b8
master
Ezgi Çiçek 5 years ago committed by Facebook Github Bot
parent d641c9ac9a
commit 2e8fc68080

@ -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 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 zero_record = VariantCostMap.empty
let mult_by_scalar cost_record scalar = map cost_record ~f:(BasicCost.mult scalar) 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 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 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 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 = let of_operation_cost operation_cost =
VariantCostMap.increase_by CostKind.OperationCost operation_cost zero_record VariantCostMap.increase_by CostKind.OperationCost operation_cost zero_record

@ -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} *)
Loading…
Cancel
Save