![]() |
ImFusion SDK 4.3
|
#include <ImFusion/Core/Timer.h>
This class can be used to help the developer to profile the run time of different parts of the same process. More...
This class can be used to help the developer to profile the run time of different parts of the same process.
Each time startTaskTimer is called, it will start registering the run time of that specific task, and it stops the timer of any other running task. the report which contains run time of each task is logged periodically in order to prevent flooding the logs.
calling startTaskTimer searches if the provided task name has been run before. If yes, then it will add the run time to its total run time, if not it will create an new entry for the task name. this search need a small overhead, but since we use unordered_map to store the tasks names, this should not slow down the execution of the process.
The following code shows a use case example:
here is the resulting report from the code above:
Public Member Functions | |
| MultiTimer (std::string_view component, int logIntervalsSeconds=5, Log::Level logLevel=Log::Level::Info) | |
| constructor of the class | |
| ~MultiTimer () | |
| the deconstructor will automatically log the run time report | |
| void | startTaskTimer (std::string_view taskName) |
| starts the timer the specified tasks, it also stops the timer of the previous task if it is still running | |
| void | stopCurrentTaskTimer (bool forcePrint=false) |
| stops the timer of the current task | |
| MultiTimer | ( | std::string_view | component, |
| int | logIntervalsSeconds = 5, | ||
| Log::Level | logLevel = Log::Level::Info ) |
constructor of the class
| component | the name of the process, which will be printed on each line of the report |
| logIntervalsSeconds | the time interval between two consecutive logs (in seconds) |
| logLevel | leg level used to print the report |
| void stopCurrentTaskTimer | ( | bool | forcePrint = false | ) |
stops the timer of the current task
| forcePrint | prints the run time report without taking in consideration logIntervalsSeconds |