35 t0(std::chrono::high_resolution_clock::now()),
46 elapsedSeconds = std::chrono::duration<double>(std::chrono::high_resolution_clock::now() - t0).count();
47 return elapsedSeconds;
59 return elapsedSeconds;
63 return std::chrono::duration<double>(std::chrono::high_resolution_clock::now() - t0).count();
72 double elapsed(std::chrono::duration<double>(std::chrono::high_resolution_clock::now() - t0).count());
73 t0=std::chrono::high_resolution_clock::now();
84 double elapsed(std::chrono::duration<double>(std::chrono::high_resolution_clock::now() - t0).count());
85 t0=std::chrono::high_resolution_clock::now();
86 std::cout<<
"\nReport ["<<s<<
"]: "<<elapsed<<
" s"<<std::endl;
89 std::chrono::high_resolution_clock::time_point t0;
90 double elapsedSeconds;
100 Dur():numIntervals(0),totalTime(0.0)
114 startTime = std::chrono::high_resolution_clock::now();
119 auto endTime = std::chrono::high_resolution_clock::now();
120 double elapsed_ns = std::chrono::duration<double, std::nano>(endTime - startTime).count();
121 totalTime += elapsed_ns;
126 double report(
const std::string& name,
bool bSilent=
false)
128 auto cur = std::chrono::high_resolution_clock::now();
129 double elapsed_ns = std::chrono::duration<double, std::nano>(cur - startTime).count();
130 totalTime += elapsed_ns;
131 if(bSilent) ss<<
"Dur ["<<name<<
"]: "<<elapsed_ns<<
" ns ("<<elapsed_ns/1e9<<
" s, sum="<<totalTime<<
" ns ( " << (totalTime/1e9) <<
")s. NumIntervals="<<numIntervals<<
"\n";
132 else std::cout<<
"Dur ["<<name<<
"]: "<<elapsed_ns<<
" ns ("<<elapsed_ns/1e9<<
" s), sum="<<totalTime<<
" ns ( " << (totalTime/1e9) <<
")s. NumIntervals="<<numIntervals<<std::endl;
137 double stopAndReport(
const std::string& name)
139 auto cur = std::chrono::high_resolution_clock::now();
140 double elapsed_ns = std::chrono::duration<double, std::nano>(cur - startTime).count();
141 totalTime += elapsed_ns;
142 std::cout<<
"Dur ["<<name<<
"]: "<<elapsed_ns<<
" ns ("<<elapsed_ns/1e9<<
" s), sum="<<totalTime<<
" ns ( " << (totalTime/1e9) <<
" s). NumIntervals="<<numIntervals<<
". Stop.\n"<<std::endl;
146 double reportTotal(
const std::string& name)
148 std::cout<<
"Dur ["<<name<<
"]: total time: "<<totalTime<<
" ns ( " << (totalTime/1e9) <<
" s). NumIntervals="<<numIntervals<<
". Stop.\n"<<std::endl;
153 std::cout<<
"Dur::unsilence():\n";
154 std::cout<<ss.str()<<std::endl;
158 double getSum()
const
166 std::chrono::high_resolution_clock::time_point startTime;
167 std::stringstream ss;
Timer class.
Definition: TimerC.h:28
double stop()
Timer stop.
Definition: TimerC.h:43
double get() const
Get the elapsed time.
Definition: TimerC.h:55
void report(const std::string &s)
Report.
Definition: TimerC.h:82
TimerC()
Constructor.
Definition: TimerC.h:34
double getSecondsSinceLastReport()
Get elapsed time since last report.
Definition: TimerC.h:70