Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
shambase::Timer Class Reference

Class Timer measures the time elapsed since the timer was started. More...

#include <shambase/include/shambase/Timer.hpp>

Public Member Functions

 Timer ()
 Constructor, init nanosec to 0.
void start ()
 Starts the timer.
void stop ()
 Stops the timer and stores the elapsed time in nanoseconds.
std::string get_time_str () const
 Converts the stored nanosecond time to a string representation.
f64 elapsed_sec () const
 Converts the stored nanosecond time to a floating point representation in seconds.

Public Attributes

plf::nanotimer timer
 Internal timer.
f64 nanosec
 Time in nanoseconds.

Detailed Description

Class Timer measures the time elapsed since the timer was started.

Definition at line 36 of file Timer.hpp.

Constructor & Destructor Documentation

◆ Timer()

shambase::Timer::Timer ( )
inline

Constructor, init nanosec to 0.

Definition at line 46 of file Timer.hpp.

Member Function Documentation

◆ elapsed_sec()

f64 shambase::Timer::elapsed_sec ( ) const
inlinenodiscard

Converts the stored nanosecond time to a floating point representation in seconds.

Returns
f64 The elapsed time in seconds.

Definition at line 88 of file Timer.hpp.

◆ get_time_str()

std::string shambase::Timer::get_time_str ( ) const
inline

Converts the stored nanosecond time to a string representation.

Returns
std::string A string representation of the elapsed time.

Definition at line 79 of file Timer.hpp.

Here is the call graph for this function:

◆ start()

void shambase::Timer::start ( )
inline

Starts the timer.

Definition at line 51 of file Timer.hpp.

◆ stop()

void shambase::Timer::stop ( )
inline

Stops the timer and stores the elapsed time in nanoseconds.

If the timer has already been stopped, calling this again updates nanosec to the new delta since start().

Definition at line 65 of file Timer.hpp.

Member Data Documentation

◆ nanosec

f64 shambase::Timer::nanosec

Time in nanoseconds.

Definition at line 43 of file Timer.hpp.

◆ timer

plf::nanotimer shambase::Timer::timer

Internal timer.

Definition at line 39 of file Timer.hpp.


The documentation for this class was generated from the following file: