AutoPas  3.0.0
Loading...
Searching...
No Matches
TraceTimer.h
Go to the documentation of this file.
1
7#pragma once
8
9#include <spdlog/spdlog.h>
10
11#include "autopas/utils/Timer.h"
12
13namespace autopas::utils {
14
21 public:
25 void start() {
26#if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_TRACE
27 _timer.start();
28#endif
29 }
30
34 long stop() {
35#if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_TRACE
36 return _timer.stop();
37#else
38 return 0;
39#endif
40 }
41
45 void reset() {
46#if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_TRACE
47 _timer.reset();
48#endif
49 }
50
54 void addTime(long nanoseconds) {
55#if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_TRACE
56 _timer.addTime(nanoseconds);
57#endif
58 }
59
63 [[nodiscard]] long getTotalTime() const {
64#if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_TRACE
65 return _timer.getTotalTime();
66#else
67 return 0;
68#endif
69 }
70
71 private:
72 // The actual timer object is only instantiated if we are logging at TRACE level.
73#if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_TRACE
74 Timer _timer;
75#endif
76};
77
78} // namespace autopas::utils
Timer class to stop times.
Definition: Timer.h:27
void start()
start the timer.
Definition: Timer.cpp:17
void reset()
Resets the timer to 0.
Definition: Timer.cpp:40
long getTotalTime() const
Get total accumulated time.
Definition: Timer.h:60
void addTime(long nanoseconds)
Adds the given amount of nanoseconds to the total time.
Definition: Timer.cpp:42
long stop()
Stops the timer and returns the time elapsed in nanoseconds since the last call to start.
Definition: Timer.cpp:25
A wrapper around autopas::utils::Timer that only compiles implementation logic if the SPDLOG_ACTIVE_L...
Definition: TraceTimer.h:20
long getTotalTime() const
Get total accumulated time.
Definition: TraceTimer.h:63
void reset()
Resets the timer to 0.
Definition: TraceTimer.h:45
void start()
start the timer.
Definition: TraceTimer.h:25
void addTime(long nanoseconds)
Adds the given amount of nanoseconds to the total time.
Definition: TraceTimer.h:54
long stop()
Stops the timer and returns the time elapsed in nanoseconds since the last call to start.
Definition: TraceTimer.h:34
In this namespace some helper classes and functions can be found used inside of AutoPas.
Definition: namespaces.h:44