holoscan::Timer
holoscan::Timer
Utility class to measure time.
This class is used to measure time. It can be used to measure the time between two points in the code, or to measure the time of a function.
The class can be used in two ways:
- Using the start() and stop() methods to measure the time between two points in the code.
- Using the constructor with the auto_start parameter set to true to measure the time of a function.
The class can also be used to print the time elapsed between two points in the code, or the time elapsed to execute a function.
The class can be used in two ways:
- Using the print() method to print the time elapsed between two points in the code.
- Using the constructor with the auto_output parameter set to true to print the time elapsed to execute a function.
Examples:
Example
Constructors
Timer
Construct a new Timer object.
The message parameter is used to print the message when the print() method is called or when the auto_output parameter is set to true and the destructor is called. The first parameter {} in the message will be replaced by the time elapsed.
auto_start is used to start the timer when the constructor is called. auto_output is used to print the time elapsed when the destructor is called. By default, auto_start and auto_output are set to true.
Parameters
The message to print when the timer is stopped.
If true, the timer is started when the constructor is called.
If true, the time elapsed is printed when the destructor is called.
Example
Destructor
~Timer
Destroy the Timer object.
If the auto_output parameter is set to true, the time elapsed is printed when the destructor is called.
Methods
start
Start the timer.
stop
Stop the timer.
Returns: The time elapsed in seconds.
elapsed_time
Return the time elapsed in seconds.
Returns: The time elapsed in seconds.
Print the time elapsed.
The message passed to the constructor is printed with the time elapsed if no message parameter is passed to the print() method.
The first parameter {} in the message will be replaced by the time elapsed.
Parameters
The message to print.