36#include <boost/algorithm/string.hpp>
63 "Call to Timer::Elapsed() done before Timer::Stop().");
64 return std::chrono::duration_cast<Seconds>(
m_end -
m_start);
78 m_elapsedRegion.insert({region, std::make_tuple<Timer::Seconds, size_t>(
83 std::get<0>(search->second) += this->
Elapsed();
84 std::get<1>(search->second) += 1;
90 std::string def(
"default");
91 char *argv =
new char[def.length() + 1];
92 std::strcpy(argv, def.c_str());
102 std::ostream &o,
int iolevel)
111 std::vector<std::string> labels{
"Region",
"Elapsed time Avg (s)",
112 "Min (s)",
"Max (s)",
113 "Count",
"IO Level"};
116 std::vector<size_t> widths;
117 for (
const auto &
label : labels)
119 widths.push_back(std::max<size_t>(
label.size() + 2, 14));
125 widths[0] = std::max<size_t>(entry.first.size() + 2, widths[0]);
129 if (comm->GetRank() == 0)
131 o <<
"-------------------------------------------\n";
132 for (
int i = 0; i < labels.size(); ++i)
134 o << std::setw(widths[i]) << labels[i];
143 auto elapsedAve = std::get<0>(item->second).count();
145 elapsedAve /= comm->GetSize();
146 auto elapsedMin = std::get<0>(item->second).count();
148 auto elapsedMax = std::get<0>(item->second).count();
151 if (comm->GetRank() == 0)
153 o << std::setw(widths[0]) << item->first << std::setw(widths[1])
154 << elapsedAve << std::setw(widths[2]) << elapsedMin
155 << std::setw(widths[3]) << elapsedMax << std::setw(widths[4])
156 << std::get<1>(item->second) << std::setw(widths[5])
157 << std::get<2>(item->second) <<
'\n';
162 for (
int i = 0; i <= iolevel; i++)
165 if (comm->GetRank() == 0)
172 if (boost::iequals(item->first,
"Execute"))
178 if (std::get<2>(item->second) == i)
181 auto elapsedAve = std::get<0>(item->second).count();
183 elapsedAve /= comm->GetSize();
184 auto elapsedMin = std::get<0>(item->second).count();
186 auto elapsedMax = std::get<0>(item->second).count();
189 if (comm->GetRank() == 0)
191 o << std::setw(widths[0]) << item->first
192 << std::setw(widths[1]) << elapsedAve
193 << std::setw(widths[2]) << elapsedMin
194 << std::setw(widths[3]) << elapsedMax
195 << std::setw(widths[4]) << std::get<1>(item->second)
196 << std::setw(widths[5]) << std::get<2>(item->second)
205std::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.