11 const std::string& className,
12 const std::string& operationName,
13 const bool plotResultInDestructor,
14 bool startToTickImmediately
17 _plotResultInDestructor(plotResultInDestructor),
18 _operationName(operationName),
21 _elapsedClockTicks(0),
23 _isRunning(startToTickImmediately) {
25 if (startToTickImmediately) {
36 if (_plotResultInDestructor) {
39 "total number of clock ticks within block (cpu-time,calendar-time): "
40 <<
"(" << getCPUTime() <<
"s"
41 <<
"," << getCalendarTime() <<
"s"
49 _startClockTicks = std::clock();
50 _startTime = std::chrono::steady_clock::now();
56 _elapsedClockTicks = std::clock() - _startClockTicks;
57 _elapsedTime = std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::steady_clock::now() - _startTime)
59 _elapsedTime = _elapsedTime / 1000000000.0;
65 double lhs =
static_cast<double>(_elapsedClockTicks);
66 double rhs =
static_cast<double>(CLOCKS_PER_SEC);
#define logInfo(methodName, logMacroMessageStream)
Wrapper macro around tarch::tarch::logging::Log to improve logging.
Watch(const std::string &className, const std::string &operationName, bool plotResultInDestructor, bool startToTickImmediately=true)
Construct a watch.
double getCalendarTime()
This method returns the elapsed calendar time between the start and stop command of the timer,...
std::clock_t getCPUTicks()
Equals getCPUTime() but returns the clock ticks instead of the time in seconds.
double getCPUTime()
Return CPU Time in Seconds.
bool isOn() const
This operation returns whether the watch is currently on.
void start()
(Re)Start the Timer
virtual ~Watch()
For standard version (): Stops the watch and plots the time spent.
tarch::logging::Log _log("exahype2::fv")