Skip to content

Commit

Permalink
Print realtive paths for longest proc analysis stats
Browse files Browse the repository at this point in the history
Summary: Easier to locate long-running procedures if we have the relative path.

Reviewed By: geralt-encore

Differential Revision: D49675909

fbshipit-source-id: 7912eb445e22c0ed14bf8b22cf9f36b8f7be0f3d
  • Loading branch information
hajduakos authored and facebook-github-bot committed Sep 30, 2023
1 parent 8ba3f7c commit eab7726
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
4 changes: 3 additions & 1 deletion infer/src/backend/ondemand.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions infer/src/base/Stats.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 )

Expand Down
2 changes: 1 addition & 1 deletion infer/src/base/Stats.mli
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit eab7726

Please sign in to comment.