@ -41,7 +41,31 @@ type stats_type =
| Reporting
| Reporting
| Driver
| Driver
let dirname_of_stats_type = function
let source_file_of_stats_type = function
| ClangLinters source_file
| ClangFrontend source_file
| ClangFrontendLinters source_file
| JavaFrontend source_file
| PythonFrontend source_file
| Backend source_file ->
Some source_file
| _ ->
None
let relative_path_of_stats_type stats_type =
let abbrev_source_file =
Option . map ~ f : DB . source_file_encoding ( source_file_of_stats_type stats_type )
in
let filename =
match abbrev_source_file with
| Some abbrev ->
F . sprintf " %s_%s.json " Config . perf_stats_prefix abbrev
| None ->
F . sprintf " %s.json " Config . perf_stats_prefix
in
let dirname =
match stats_type with
| ClangLinters _ ->
| ClangLinters _ ->
Config . frontend_stats_dir_name
Config . frontend_stats_dir_name
| ClangFrontend _ ->
| ClangFrontend _ ->
@ -58,6 +82,8 @@ let dirname_of_stats_type = function
Config . reporting_stats_dir_name
Config . reporting_stats_dir_name
| Driver ->
| Driver ->
Config . driver_stats_dir_name
Config . driver_stats_dir_name
in
Filename . concat dirname filename
let string_of_stats_type = function
let string_of_stats_type = function
@ -79,18 +105,6 @@ let string_of_stats_type = function
" driver "
" driver "
let source_file_of_stats_type = function
| ClangLinters source_file
| ClangFrontend source_file
| ClangFrontendLinters source_file
| JavaFrontend source_file
| PythonFrontend source_file
| Backend source_file ->
Some source_file
| _ ->
None
let to_json ps =
let to_json ps =
let time =
let time =
Option . value_map ~ default : [] ps . time ~ f : ( fun time_perf ->
Option . value_map ~ default : [] ps . time ~ f : ( fun time_perf ->
@ -312,13 +326,8 @@ let report stats_kind file stats_type () =
let registered = String . Table . create ~ size : 4 ()
let registered = String . Table . create ~ size : 4 ()
let get_relative_path filename stats_type =
let register_report stats_kind stats_type =
let dirname = dirname_of_stats_type stats_type in
let relative_path = relative_path_of_stats_type stats_type in
Filename . concat dirname filename
let register_report stats_kind filename stats_type =
let relative_path = get_relative_path filename stats_type in
let absolute_path = Filename . concat Config . results_dir relative_path in
let absolute_path = Filename . concat Config . results_dir relative_path in
let f = report stats_kind absolute_path stats_type in
let f = report stats_kind absolute_path stats_type in
(* make sure to not double register the same perf stat report *)
(* make sure to not double register the same perf stat report *)
@ -331,13 +340,13 @@ let register_report stats_kind filename stats_type =
let dummy_reporter () = ()
let dummy_reporter () = ()
let get_reporter filename stats_type =
let get_reporter stats_type =
let relative_path = get_relative_path filenam e stats_type in
let relative_path = relative_path_of_stats_typ e stats_type in
String . Table . find registered relative_path | > Option . value ~ default : dummy_reporter
String . Table . find registered relative_path | > Option . value ~ default : dummy_reporter
let register_report_at_exit filename stats_type =
let register_report_at_exit stats_type =
register_report TimeAndMemory filename stats_type ;
let relative_path = relative_path_of_stats_type stats_type in
Epilogues . register
register _report TimeAndMemory stats_type ;
~ f : ( get_reporter filename stats_type )
Epilogues . register ~ f : ( get_reporter stats_type )
( string_of_stats_type stats_type ^ " stats reporting in " ^ filename )
( string_of_stats_type stats_type ^ " stats reporting in " ^ relative_path )