ExaDG
Loading...
Searching...
No Matches
timer_tree.h
1/* ______________________________________________________________________
2 *
3 * ExaDG - High-Order Discontinuous Galerkin for the Exa-Scale
4 *
5 * Copyright (C) 2021 by the ExaDG authors
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 * ______________________________________________________________________
20 */
21
22#ifndef INCLUDE_EXADG_UTILITIES_TIMER_TREE_H_
23#define INCLUDE_EXADG_UTILITIES_TIMER_TREE_H_
24
25// C++
26#include <memory>
27#include <string>
28#include <vector>
29
30// deal.II
31#include <deal.II/base/conditional_ostream.h>
32
33namespace ExaDG
34{
36{
37public:
41 TimerTree();
42
47 void
48 clear();
49
56 void
57 insert(std::vector<std::string> const ids, double const wall_time);
58
66 void
67 insert(std::vector<std::string> ids,
68 std::shared_ptr<TimerTree> sub_tree,
69 std::string const new_name = "");
70
75 void
76 print_plain(dealii::ConditionalOStream const & pcout) const;
77
88 void
89 print_level(dealii::ConditionalOStream const & pcout, unsigned int const level) const;
90
94 unsigned int
95 get_max_level() const;
96
97private:
102 void
103 copy_from(std::shared_ptr<TimerTree> other);
104
108 std::vector<std::string>
109 erase_first(std::vector<std::string> const & in) const;
110
115 double
116 get_average_wall_time() const;
117
122 unsigned int
123 get_length() const;
124
130 void
131 do_print_plain(dealii::ConditionalOStream const & pcout,
132 unsigned int const offset,
133 unsigned int const length) const;
134
138 void
139 do_print_level(dealii::ConditionalOStream const & pcout,
140 unsigned int const level,
141 unsigned int const offset,
142 unsigned int const length) const;
143
149 void
150 print_name(dealii::ConditionalOStream const & pcout,
151 unsigned int const offset,
152 unsigned int const length,
153 bool const new_line) const;
154
161 void
162 print_own(dealii::ConditionalOStream const & pcout,
163 unsigned int const offset,
164 unsigned int const length,
165 bool const relative = false,
166 double const ref_time = -1.0) const;
167
174 void
175 print_direct_children(dealii::ConditionalOStream const & pcout,
176 unsigned int const offset,
177 unsigned int const length,
178 bool const relative = false,
179 double const ref_time = -1.0) const;
180
181 std::string id;
182
183 struct Data
184 {
185 Data() : wall_time(0.0)
186 {
187 }
188
189 double wall_time;
190 };
191
192 std::shared_ptr<Data> data;
193
194 std::vector<std::shared_ptr<TimerTree>> sub_trees;
195
196 static unsigned int const offset_per_level = 2;
197 static unsigned int const precision = 2;
198};
199} // namespace ExaDG
200
201
202#endif /* INCLUDE_EXADG_UTILITIES_TIMER_TREE_H_ */
Definition timer_tree.h:36
void clear()
Definition timer_tree.cpp:39
void insert(std::vector< std::string > const ids, double const wall_time)
Definition timer_tree.cpp:47
unsigned int get_max_level() const
Definition timer_tree.cpp:197
void print_plain(dealii::ConditionalOStream const &pcout) const
Definition timer_tree.cpp:165
void print_level(dealii::ConditionalOStream const &pcout, unsigned int const level) const
Definition timer_tree.cpp:175
TimerTree()
Definition timer_tree.cpp:34
Definition driver.cpp:33