36#include <boost/algorithm/string.hpp>
61 "Call to Timer::Elapsed() done before Timer::Stop().");
62 return std::chrono::duration_cast<Seconds>(
m_end -
m_start);
76 m_elapsedRegion.insert({region, std::make_tuple<Timer::Seconds, size_t>(
81 std::get<0>(search->second) += this->
Elapsed();
82 std::get<1>(search->second) += 1;
88 std::string def(
"default");
89 char *argv =
new char[def.length() + 1];
90 std::strcpy(argv, def.c_str());
100 std::ostream &o,
int iolevel)
109 std::vector<std::string> labels{
"Region",
"Elapsed time Avg (s)",
110 "Min (s)",
"Max (s)",
111 "Count",
"IO Level"};
114 std::vector<size_t> widths;
115 for (
const auto &
label : labels)
117 widths.push_back(std::max<size_t>(
label.size() + 2, 14));
123 widths[0] = std::max<size_t>(entry.first.size() + 2, widths[0]);
127 if (comm->GetRank() == 0)
129 o <<
"-------------------------------------------\n";
130 for (
int i = 0; i < labels.size(); ++i)
132 o << std::setw(widths[i]) << labels[i];
141 auto elapsedAve = std::get<0>(item->second).count();
143 elapsedAve /= comm->GetSize();
144 auto elapsedMin = std::get<0>(item->second).count();
146 auto elapsedMax = std::get<0>(item->second).count();
149 if (comm->GetRank() == 0)
151 o << std::setw(widths[0]) << item->first << std::setw(widths[1])
152 << elapsedAve << std::setw(widths[2]) << elapsedMin
153 << std::setw(widths[3]) << elapsedMax << std::setw(widths[4])
154 << std::get<1>(item->second) << std::setw(widths[5])
155 << std::get<2>(item->second) <<
'\n';
160 for (
int i = 0; i <= iolevel; i++)
163 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.