41 start(std::string label,
bool reset =
false)
43 auto it = timers.find(label);
44 if (it != timers.end())
52 timers[label] = dealii::Timer();
53 timers[label].start();
58 stop(std::string label)
60 return timers[label].stop();
64 stop_and_set(std::string label)
66 double value = stop(label);
71 stop_and_put(std::string label)
73 double value = stop(label);
80 vec.push_back(std::map<std::string, double>());
84 put(std::string label,
double value)
const
86 auto &map = vec.back();
87 auto it = map.find(label);
95 get(std::string label)
const
97 auto &map = vec.back();
98 auto it = map.find(label);
106 set(std::string label,
double value)
const
108 auto &map = vec.back();
109 auto it = map.find(label);
117 print(FILE *f,
bool do_horizontal =
true)
const
120 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
125 std::vector<std::string> header;
127 for (
auto &map : vec)
129 if (std::find(header.begin(), header.end(), it.first) == header.end())
130 header.push_back(it.first);
132 std::sort(header.begin(), header.end());
136 for (
auto it : header)
137 fprintf(f,
"%12s", it.c_str());
140 for (
auto &map : vec)
144 for (
auto h : header)
146 auto it = map.find(h);
148 fprintf(f,
"%12.4e", 0.0);
150 fprintf(f,
"%12.4e", it->second);
158 for (
auto head : header)
160 length = std::max(length, head.size());
163 const auto hline = [&]() {
165 printf(
"+%s+", std::string((
int)length + 5,
'-').c_str());
166 for (
auto &map : vec)
170 fprintf(f,
"--------------+");
178 printf(
"| %-*s|", (
int)length + 4,
"category");
180 for (
auto &map : vec)
184 fprintf(f,
" item %2d |", counter++);
191 for (
auto head : header)
193 fprintf(f,
"| %-*s|", (
int)length + 4, head.c_str());
194 for (
auto &map : vec)
198 auto it = map.find(head);
200 fprintf(f,
" %12.4e |", 0.0);
202 fprintf(f,
" %12.4e |", it->second);
214 print(
bool do_horizontal =
true)
const
216 this->print(stdout, do_horizontal);
221 print(std::string filename)
const
223 FILE *f = fopen(filename.c_str(),
"w");
229 mutable std::vector<std::map<std::string, double>> vec;
230 std::map<std::string, dealii::Timer> timers;