43 #ifndef __H__UG__STOPWATCH_H__
44 #define __H__UG__STOPWATCH_H__
81 return 1.0*delta/CLOCKS_PER_SEC;
99 gettimeofday(&time, NULL);
100 return time.tv_sec + time.tv_usec/1000000.0;
105 return clock() / ((double)CLOCKS_PER_SEC);
132 begin = std::chrono::high_resolution_clock::now();
133 end = std::chrono::high_resolution_clock::now();
146 begin = std::chrono::high_resolution_clock::now();
158 end = std::chrono::high_resolution_clock::now();
176 out <<
s.ms() <<
" ms";
193 if (
bRunning )
end = std::chrono::high_resolution_clock::now();
194 return std::chrono::duration_cast<std::chrono::milliseconds> (
end-
begin).count();
197 return (
end - beg ) * 1000.0;
204 std::chrono::high_resolution_clock::time_point
begin;
207 std::chrono::high_resolution_clock::time_point
end;
Definition: stopwatch.h:67
double cuckoo()
returns total time (in seconds)
Definition: stopwatch.h:85
clock_t m_tlaunch
Definition: stopwatch.h:89
double toc()
returns time since last tic
Definition: stopwatch.h:75
void tic()
Definition: stopwatch.h:72
clock_t m_tdone
Definition: stopwatch.h:90
clock_t m_ttotal
Definition: stopwatch.h:91
CuckooClock()
Definition: stopwatch.h:70
Stopwatch class for quickly taking times.
Definition: stopwatch.h:124
void stop()
Stops the Stopwatch.
Definition: stopwatch.h:156
void start()
Starts the Stopwatch.
Definition: stopwatch.h:143
double ms()
Returns milliseconds since call of start.
Definition: stopwatch.h:191
std::chrono::high_resolution_clock::time_point end
Number of microseconds since begin.
Definition: stopwatch.h:207
std::chrono::high_resolution_clock::time_point begin
Time point of the start of Stopwatch.
Definition: stopwatch.h:204
bool bRunning
Flag indicating state of Stopwatch.
Definition: stopwatch.h:215
friend std::ostream & operator<<(std::ostream &out, Stopwatch &s)
Prints number of milliseconds since call of start() to ostream.
Definition: stopwatch.h:175
Stopwatch()
Default constructor for the Stopwatch.
Definition: stopwatch.h:129
double get_clock_s()
Definition: stopwatch.h:103