27 Sentry(StdTimer& parent, std::string phase)
31 m_start = std::chrono::steady_clock::now();
36 std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now();
37 std::chrono::duration<double> time_span = std::chrono::duration_cast<std::chrono::duration<double>>(end - m_start);
39 m_parent.add(m_phase, time_span.count());
45 std::chrono::steady_clock::time_point m_start;
52 for (
auto& iter : m_counters)
56 void add(std::string
const& phase,
double value)
58 auto iter = m_counters.find(phase);
59 if (iter == m_counters.end())
60 m_counters[phase] = value;
62 iter->second += value;
65 double operator()(std::string
const& phase)
const
67 auto iter = m_counters.find(phase);
68 if (iter == m_counters.end())
74 void printInfo(
const std::string& msg)
const
76 std::cout <<
"================================" << std::endl;
77 std::cout <<
"PERF INFO : " << msg << std::endl;
78 for (
auto const& iter : m_counters) {
80 std::cout << std::format(
"{:10}:{:.3e}\n",iter.first,iter.second);
82 std::cout << iter.first<<
":"<<iter.second<<std::endl ;
85 std::cout <<
"================================" << std::endl;
88 void printInfo(std::ostream& out,
const std::string& msg)
const
90 out << msg << std::endl;
91 out <<
"================================" << std::endl;
92 out <<
"PERF INFO : " << std::endl;
93 for (
auto const& iter : m_counters) {
95 out << std::format(
"{:10}:{:.3e}\n",iter.first,iter.second);
97 out << iter.first<<
":"<<iter.second<<std::endl ;
100 out <<
"================================" << std::endl;
104 std::map<std::string, double> m_counters;