diff --git a/infer/src/backend/ondemand.ml b/infer/src/backend/ondemand.ml index a9689eeece0..7646aac5248 100644 --- a/infer/src/backend/ondemand.ml +++ b/infer/src/backend/ondemand.ml @@ -130,7 +130,9 @@ let run_proc_analysis exe_env tenv ?specialization ?caller_pname callee_pdesc = fun () -> let elapsed = Mtime_clock.count start_time in let duration_us = IMtime.span_to_us_int elapsed in - Stats.add_proc_duration_us (Procname.to_string callee_pname) duration_us ; + let file = SourceFile.to_rel_path callee_attributes.loc.file in + let pname = Procname.to_string callee_pname in + Stats.add_proc_duration_us file pname duration_us ; L.(debug Analysis Medium) "Elapsed analysis time: %a: %a@\n" Procname.pp callee_pname Mtime.Span.pp elapsed in diff --git a/infer/src/base/Stats.ml b/infer/src/base/Stats.ml index 46c217e25ea..2ffd578f7e8 100644 --- a/infer/src/base/Stats.ml +++ b/infer/src/base/Stats.ml @@ -10,13 +10,13 @@ module L = Logging module PulseSumCountMap = Caml.Map.Make (Int) module DurationItem = struct - type t = {duration_us: int; pname: string} [@@deriving equal] + type t = {duration_us: int; file: string; pname: string} [@@deriving equal] - let dummy = {duration_us= 0; pname= ""} + let dummy = {duration_us= 0; file= ""; pname= ""} let compare {duration_us= dr1} {duration_us= dr2} = Int.compare dr1 dr2 - let pp f {pname; duration_us} = F.fprintf f "%5dus: %s" duration_us pname + let pp f {pname; file; duration_us} = F.fprintf f "%5dus: %s: %s" duration_us file pname end module LongestProcDurationHeap = struct @@ -167,9 +167,9 @@ let add_pulse_summaries_count n = PulseSumCountMap.update n (fun i -> Some (1 + Option.value ~default:0 i)) counters ) -let add_proc_duration_us pname duration_us = +let add_proc_duration_us file pname duration_us = update_with Fields.longest_proc_duration_heap ~f:(fun heap -> - let new_elt = DurationItem.{pname; duration_us} in + let new_elt = DurationItem.{pname; file; duration_us} in LongestProcDurationHeap.update new_elt heap ; heap ) diff --git a/infer/src/base/Stats.mli b/infer/src/base/Stats.mli index b2b394923a1..d61c2261b1f 100644 --- a/infer/src/base/Stats.mli +++ b/infer/src/base/Stats.mli @@ -42,7 +42,7 @@ val add_pulse_interrupted_loops : int -> unit val add_pulse_summaries_count : int -> unit -val add_proc_duration_us : string -> int -> unit +val add_proc_duration_us : string -> string -> int -> unit val incr_topl_reachable_calls : unit -> unit