Timer
¶
Defined in header <Kokkos_Timer.hpp>
which is included from <Kokkos_Core.hpp>
Usage¶
Kokkos::Timer timer;
double time = timer.seconds();
timer.reset();
Interface¶
-
class Timer¶
A high-resolution timer class for measuring elapsed time.
Note
This class is intended for “quick and dirty” timing as well as situations where timing is meant to be “always on”. For serious performance profiling, it is recommended to use the Kokkos Tools API. Kokkos Tools provides the flexibility to enable or disable profiling at runtime without modifying your application, avoiding the need to clutter your code with explicit timer objects.
-
Timer()¶
Constructs a new Timer instance and immediately starts the clock.
The timer is initialized with the current time, marking the beginning of the measurement period.
-
double seconds() const¶
- Returns:
The number of seconds that have elapsed since the timer was started or last reset.
-
void reset()¶
Resets the timer, setting the start time to the current time.
This function effectively restarts the measurement period without creating a new Timer object.
-
Timer()¶
Example¶
Timer timer;
// ...
double time1 = timer.seconds();
timer.reset();
// ...
double time2 = timer.seconds();