STIR
6.2.0
|
High-resolution timer. More...
#include "stir/HighResWallClockTimer.h"
Public Member Functions | |
HighResWallClockTimer (void) | |
Create a timer. More... | |
virtual | ~HighResWallClockTimer (void) |
Destroy a timer. More... | |
void | start (bool bReset=false) |
Start a timer. More... | |
void | stop (void) |
Stop a running timer. More... | |
void | reset (void) |
Reset a timer. More... | |
bool | is_running (void) |
Check if a timer is running. More... | |
int | get_sec (void) |
Returns the number of whole seconds elapsed. More... | |
int | get_nanosec (void) |
Returns the number of nanoseconds that elapsed on top of whatever get_sec() returned. More... | |
double | value (void) |
Returns the elapsed time (in seconds) More... | |
Static Public Member Functions | |
static int | get_resolution_in_nanosecs (void) |
Attempts to guess the timer resolution. More... | |
High-resolution timer.
This timer measures wall-clock time. Implementation is OS specific to try to use high-resolution timers. It is not derived from stir::Timer to avoid the overhead of calling a virtual function.
You have to call stop() before getting the value. You have to call reset() if you wish to use the same timer to measure several separate time intervals, otherwise the time will be accumulated.
|
inline |
|
inlinevirtual |
Destroy a timer.
The timer must not be running.
|
inline |
Start a timer.
bReset | indicates whether the elapsed time should be reset before the timer is started. The timer must not be running if asking to reset. |
References reset().
Referenced by distributed::receive_and_construct_exam_and_proj_data_info_ptr(), distributed::receive_and_construct_viewgram(), distributed::receive_and_initialize_projectors(), distributed::receive_and_set_image_parameters(), distributed::receive_bool_value(), distributed::receive_double_values(), distributed::receive_image_values_and_fill_image_ptr(), distributed::receive_int_value(), distributed::receive_int_values(), distributed::receive_string(), distributed::reduce_output_image(), distributed::reduce_received_output_image(), stir::GeometryBlocksOnCylindricalTests::run_tests(), stir::BlocksTests::run_tests(), distributed::send_bool_value(), distributed::send_double_values(), distributed::send_exam_and_proj_data_info(), distributed::send_image_estimate(), distributed::send_image_parameters(), distributed::send_int_value(), distributed::send_int_values(), distributed::send_string(), distributed::send_viewgram(), and stir::ScatterSimulation::set_use_cache().
|
inline |
Stop a running timer.
When a timer is stopped (=not running), get_sec(), get_nanosec(), and value() can be used to obtain elapsed time.
Referenced by distributed::receive_and_construct_exam_and_proj_data_info_ptr(), distributed::receive_and_construct_viewgram(), distributed::receive_and_initialize_projectors(), distributed::receive_and_set_image_parameters(), distributed::receive_bool_value(), distributed::receive_double_values(), distributed::receive_image_values_and_fill_image_ptr(), distributed::receive_int_value(), distributed::receive_int_values(), distributed::receive_string(), distributed::reduce_output_image(), distributed::reduce_received_output_image(), stir::GeometryBlocksOnCylindricalTests::run_tests(), stir::BlocksTests::run_tests(), distributed::send_bool_value(), distributed::send_double_values(), distributed::send_exam_and_proj_data_info(), distributed::send_image_estimate(), distributed::send_image_parameters(), distributed::send_int_value(), distributed::send_int_values(), distributed::send_string(), distributed::send_viewgram(), and stir::ScatterSimulation::set_use_cache().
|
inline |
Reset a timer.
Sets the elapsed time to zero. The timer must not be running.
Referenced by HighResWallClockTimer(), distributed::receive_and_construct_exam_and_proj_data_info_ptr(), distributed::receive_and_construct_viewgram(), distributed::receive_and_initialize_projectors(), distributed::receive_and_set_image_parameters(), distributed::receive_bool_value(), distributed::receive_double_values(), distributed::receive_image_values_and_fill_image_ptr(), distributed::receive_int_value(), distributed::receive_int_values(), distributed::receive_string(), distributed::reduce_output_image(), distributed::reduce_received_output_image(), stir::BlocksTests::run_tests(), distributed::send_bool_value(), distributed::send_double_values(), distributed::send_exam_and_proj_data_info(), distributed::send_image_estimate(), distributed::send_image_parameters(), distributed::send_int_value(), distributed::send_int_values(), distributed::send_string(), distributed::send_viewgram(), and start().
|
inline |
Check if a timer is running.
Returns true if the timer is running, or false otherwise
|
inline |
|
inline |
|
inline |
Returns the elapsed time (in seconds)
The timer must not be running
References get_nanosec(), and get_sec().
Referenced by distributed::receive_and_construct_exam_and_proj_data_info_ptr(), distributed::receive_and_construct_viewgram(), distributed::receive_and_initialize_projectors(), distributed::receive_and_set_image_parameters(), distributed::receive_bool_value(), distributed::receive_double_values(), distributed::receive_image_values_and_fill_image_ptr(), distributed::receive_int_value(), distributed::receive_int_values(), distributed::receive_string(), distributed::reduce_output_image(), distributed::reduce_received_output_image(), stir::BlocksTests::run_tests(), distributed::send_bool_value(), distributed::send_double_values(), distributed::send_exam_and_proj_data_info(), distributed::send_image_estimate(), distributed::send_image_parameters(), distributed::send_int_value(), distributed::send_int_values(), distributed::send_string(), distributed::send_viewgram(), and stir::ScatterSimulation::set_use_cache().
|
inlinestatic |
Attempts to guess the timer resolution.
get_resolution_in_nanosecs() is by no means accurate. The only thing that is guranteed is that timer resolution is not less than the value returned by get_resolution_in_nanosecs().
On Win32, returns more or less precise resolution (can be slightly rounded if the actual resolution can't be expressed as an integer number of nanoseconds)