20using std::list, std::string, std::invalid_argument, std::cout, std::endl, std::to_string, std::ios;
21namespace chrono = std::chrono;
24namespace MultiProcess {
40 ProcessTimer::duration_map_t::key_type sec_name;
41 ProcessTimer::duration_map_t::mapped_type duration_list;
43 std::tie(sec_name, duration_list) = durations_element;
44 if (sec_name != to_return) {
50 throw ::invalid_argument(
"section name " + to_return +
51 " not found in timer map, so it cannot"
61 }
else if (it->second.size() % 2 != 0) {
63 throw ::invalid_argument(
"Section name " + section_name +
64 " timer has already started, and was not stopped before calling `start_timer`");
67 it->second.push_back(chrono::steady_clock::now());
76 throw ::invalid_argument(
"Section name " + section_name +
" timer was never started!");
77 }
else if (it->second.size() % 2 == 0) {
79 throw ::invalid_argument(
"Section name " + section_name +
80 " timer does exist, but was not started before calling `end_timer`");
83 it->second.push_back(chrono::steady_clock::now());
98 ProcessTimer::duration_map_t::key_type sec_name;
99 ProcessTimer::duration_map_t::mapped_type duration_list;
101 std::tie(sec_name, duration_list) = durations_element;
102 if (to_print !=
"all" && sec_name != to_print)
106 long total_duration = 0;
107 cout <<
"Section name " << sec_name <<
":" << endl;
108 for (
auto it = duration_list.begin(); it != duration_list.end(); ++it) {
109 long duration = chrono::duration_cast<chrono::milliseconds>(*std::next(it) - *it).count();
110 cout <<
"Duration " << i <<
": " << duration <<
"ms +" << endl;
111 total_duration += duration;
114 cout <<
"--------------------" << endl <<
"Total: " << total_duration <<
"ms" << endl << endl;
121 ProcessTimer::duration_map_t::key_type sec_name;
122 ProcessTimer::duration_map_t::mapped_type duration_list;
124 std::tie(sec_name, duration_list) = durations_element;
126 cout <<
"Section name " << sec_name <<
":" << endl;
127 for (
auto it = duration_list.begin(); it != duration_list.end(); ++it) {
128 long duration_since_begin_start =
131 long duration_since_begin_end =
134 cout <<
"Duration " << i <<
": " << duration_since_begin_start <<
"ms-->" << duration_since_begin_end <<
"ms"
147 list<long> durations_since_begin;
149 ProcessTimer::duration_map_t::key_type sec_name;
150 ProcessTimer::duration_map_t::mapped_type duration_list;
152 std::tie(sec_name, duration_list) = durations_element;
153 durations_since_begin.clear();
154 for (
auto const ×tamp : duration_list) {
155 durations_since_begin.push_back(
158 j[sec_name] = durations_since_begin;
160 file << std::setw(4) << j;
169 meta.push_back(std::move(
data));
170 j[
"metadata"] = meta;
172 file << std::setw(4) << j;
184 meta[
"write_interval"] =
true;
185 j[
"metadata"] = meta;
187 file << std::setw(4) << j;
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
static void add_metadata(json data)
static void print_timestamps()
static void set_write_interval(int write_interval)
static void print_durations(std::string to_print="all")
static std::chrono::time_point< std::chrono::steady_clock > begin
static std::list< std::chrono::time_point< std::chrono::steady_clock > > get_durations(std::string section_name)
static pid_t get_process()
static std::chrono::time_point< std::chrono::steady_clock > previous_write
static void start_timer(std::string section_name)
std::map< std::string, std::list< std::chrono::time_point< std::chrono::steady_clock > > > duration_map_t
static int write_interval
static duration_map_t durations
static void end_timer(std::string section_name)
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...