Reviewed By: mbouaziz Differential Revision: D15853454 fbshipit-source-id: 41ec36392master
parent
0f43930f40
commit
898dd104c8
@ -0,0 +1,50 @@
|
|||||||
|
(*
|
||||||
|
* 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
|
||||||
|
|
||||||
|
type issue_spec =
|
||||||
|
{ extract_cost_f: Jsonbug_t.cost_item -> Jsonbug_t.cost_info
|
||||||
|
; name: string
|
||||||
|
; threshold: int option
|
||||||
|
; complexity_increase_issue: is_on_cold_start:bool -> IssueType.t
|
||||||
|
; expensive_issue: is_on_cold_start:bool -> IssueType.t
|
||||||
|
; zero_issue: IssueType.t
|
||||||
|
; infinite_issue: IssueType.t
|
||||||
|
; top_and_bottom: bool }
|
||||||
|
|
||||||
|
module CostKindMap = struct
|
||||||
|
include PrettyPrintable.MakePPMap (CostKind)
|
||||||
|
|
||||||
|
type no_value = |
|
||||||
|
|
||||||
|
let iter2 map1 map2 ~f =
|
||||||
|
let (_ : no_value t) =
|
||||||
|
merge
|
||||||
|
(fun k v1_opt v2_opt ->
|
||||||
|
(match (v1_opt, v2_opt) with Some v1, Some v2 -> f k v1 v2 | _ -> ()) ;
|
||||||
|
None )
|
||||||
|
map1 map2
|
||||||
|
in
|
||||||
|
()
|
||||||
|
end
|
||||||
|
|
||||||
|
let enabled_cost_map =
|
||||||
|
List.fold CostKind.enabled_cost_kinds ~init:CostKindMap.empty
|
||||||
|
~f:(fun acc CostKind.{kind; top_and_bottom} ->
|
||||||
|
let kind_spec =
|
||||||
|
{ name= Format.asprintf "The %a" CostKind.pp kind
|
||||||
|
; threshold= (if Config.use_cost_threshold then CostKind.to_threshold kind else None)
|
||||||
|
; extract_cost_f= (fun c -> CostKind.to_json_cost_info c kind)
|
||||||
|
; complexity_increase_issue=
|
||||||
|
(fun ~is_on_cold_start -> IssueType.complexity_increase ~kind ~is_on_cold_start)
|
||||||
|
; expensive_issue=
|
||||||
|
(fun ~is_on_cold_start -> IssueType.expensive_cost_call ~kind ~is_on_cold_start)
|
||||||
|
; zero_issue= IssueType.zero_cost_call ~kind
|
||||||
|
; infinite_issue= IssueType.infinite_cost_call ~kind
|
||||||
|
; top_and_bottom }
|
||||||
|
in
|
||||||
|
CostKindMap.add kind kind_spec acc )
|
@ -0,0 +1,26 @@
|
|||||||
|
(*
|
||||||
|
* 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
|
||||||
|
|
||||||
|
type issue_spec =
|
||||||
|
{ extract_cost_f: Jsonbug_t.cost_item -> Jsonbug_t.cost_info
|
||||||
|
; name: string
|
||||||
|
; threshold: int option
|
||||||
|
; complexity_increase_issue: is_on_cold_start:bool -> IssueType.t
|
||||||
|
; expensive_issue: is_on_cold_start:bool -> IssueType.t
|
||||||
|
; zero_issue: IssueType.t
|
||||||
|
; infinite_issue: IssueType.t
|
||||||
|
; top_and_bottom: bool }
|
||||||
|
|
||||||
|
module CostKindMap : sig
|
||||||
|
include PrettyPrintable.PPMap with type key = CostKind.t
|
||||||
|
|
||||||
|
val iter2 : 'a t -> 'b t -> f:(key -> 'a -> 'b -> unit) -> unit
|
||||||
|
end
|
||||||
|
|
||||||
|
val enabled_cost_map : issue_spec CostKindMap.t
|
Loading…
Reference in new issue