37 #include <boost/algorithm/string.hpp>
44 namespace LibUtilities
64 "Call to Timer::Elapsed() done before Timer::Stop().");
65 return std::chrono::duration_cast<Seconds>(
m_end -
m_start);
79 m_elapsedRegion.insert({region, std::make_tuple<Timer::Seconds, size_t>(
84 std::get<0>(search->second) += this->
Elapsed();
85 std::get<1>(search->second) += 1;
91 std::string def(
"default");
92 char *argv =
new char[def.length() + 1];
93 std::strcpy(argv, def.c_str());
103 std::ostream &o,
int iolevel)
112 std::vector<std::string> labels{
"Region",
"Elapsed time Avg (s)",
113 "Min (s)",
"Max (s)",
114 "Count",
"IO Level"};
117 std::vector<size_t> widths;
118 for (
const auto &
label : labels)
120 widths.push_back(std::max<size_t>(
label.size() + 2, 14));
126 widths[0] = std::max<size_t>(entry.first.size() + 2, widths[0]);
130 if (comm->GetRank() == 0)
132 o <<
"-------------------------------------------\n";
133 for (
int i = 0; i < labels.size(); ++i)
135 o << std::setw(widths[i]) << labels[i];
144 auto elapsedAve = std::get<0>(item->second).count();
146 elapsedAve /= comm->GetSize();
147 auto elapsedMin = std::get<0>(item->second).count();
149 auto elapsedMax = std::get<0>(item->second).count();
152 if (comm->GetRank() == 0)
154 o << std::setw(widths[0]) << item->first << std::setw(widths[1])
155 << elapsedAve << std::setw(widths[2]) << elapsedMin
156 << std::setw(widths[3]) << elapsedMax << std::setw(widths[4])
157 << std::get<1>(item->second) << std::setw(widths[5])
158 << std::get<2>(item->second) <<
'\n';
163 for (
int i = 0; i <= iolevel; i++)
166 if (comm->GetRank() == 0)
173 if (boost::iequals(item->first,
"Execute"))
179 if (std::get<2>(item->second) == i)
182 auto elapsedAve = std::get<0>(item->second).count();
184 elapsedAve /= comm->GetSize();
185 auto elapsedMin = std::get<0>(item->second).count();
187 auto elapsedMax = std::get<0>(item->second).count();
190 if (comm->GetRank() == 0)
192 o << std::setw(widths[0]) << item->first
193 << std::setw(widths[1]) << elapsedAve
194 << std::setw(widths[2]) << elapsedMin
195 << std::setw(widths[3]) << elapsedMax
196 << std::setw(widths[4]) << std::get<1>(item->second)
197 << std::setw(widths[5]) << std::get<2>(item->second)
205 std::map<std::string, std::tuple<Timer::Seconds, size_t, int>>
#define ASSERTL0(condition, msg)
static void PrintElapsedRegions()
Print elapsed time and call count for each region with default serial communicator.
NekDouble TimePerTest(unsigned int n)
Returns amount of seconds per iteration in a test with n iterations.
void AccumulateRegion(std::string, int iolevel=0)
Accumulate elapsed time for a region.
static std::map< std::string, std::tuple< Seconds, size_t, int > > m_elapsedRegion
std::chrono::duration< NekDouble > Seconds
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
std::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
The above copyright notice and this permission notice shall be included.