[cost] Add average runtime to message

Reviewed By: ezgicicek

Differential Revision: D20246911

fbshipit-source-id: b018bb257
master
Sungkeun Cho 5 years ago committed by Facebook Github Bot
parent 3d74e66b48
commit baf770680b

@ -250,10 +250,14 @@ let issue_of_cost kind CostIssues.{complexity_increase_issue; unreachable_issue;
if is_on_ui_thread then
Format.asprintf "%a %s" MarkupFormatter.pp_bold
"This function is called on the UI Thread!" common_msg
else if ExternalPerfData.in_profiler_data_map procname then
Format.asprintf "%a %s" MarkupFormatter.pp_bold
"This function is called during cold start!" common_msg
else ""
else
Option.value_map (ExternalPerfData.get_avg_inclusive_time_opt procname) ~default:""
~f:(fun avg_inclusive_time ->
let pp_avg_inclusive_time f =
Format.fprintf f "(avg inclusive CPU time was %.1f ms)" avg_inclusive_time
in
Format.asprintf "%a %t %s" MarkupFormatter.pp_bold
"This function is called during cold start!" pp_avg_inclusive_time common_msg )
in
let msg =
(* Java Only *)

@ -73,14 +73,28 @@ let _read_file_perf_data fname =
let read_file_flag = ref false
let prepare_perf_data fname =
if not !read_file_flag then (
_read_file_perf_data fname ;
read_file_flag := true ) ;
if PerfProfilerDataMap.is_empty !global_perf_profiler_data then
L.(debug Analysis Medium) "@\n\n[Perf Profiler Log] WARNING: EMPTY PERF PROFILER DATA@\n"
let in_profiler_data_map key =
match Config.perf_profiler_data_file with
| Some fname ->
if not !read_file_flag then (
_read_file_perf_data fname ;
read_file_flag := true ) ;
if PerfProfilerDataMap.is_empty !global_perf_profiler_data then
L.(debug Analysis Medium) "@\n\n[Perf Profiler Log] WARNING: EMPTY PERF PROFILER DATA@\n" ;
prepare_perf_data fname ;
PerfProfilerDataMap.mem key !global_perf_profiler_data
| _ ->
false
let get_avg_inclusive_time_opt key =
let open IOption.Let_syntax in
let* fname = Config.perf_profiler_data_file in
prepare_perf_data fname ;
let+ {Perf_profiler_t.avg_inclusive_cpu_time_ms} =
PerfProfilerDataMap.find_opt key !global_perf_profiler_data
in
avg_inclusive_cpu_time_ms

@ -8,3 +8,5 @@
open! IStd
val in_profiler_data_map : Procname.t -> bool
val get_avg_inclusive_time_opt : Procname.t -> float option

Loading…
Cancel
Save