mCRL2
|
Simple timer to time the CPU time used by a piece of code. More...
#include <execution_timer.h>
Classes | |
struct | timing |
Pair of start and finish times. More... | |
Public Member Functions | |
execution_timer (const std::string &tool_name="", std::string const &filename="") | |
Constructor of a simple execution timer. | |
~execution_timer () | |
Destructor. | |
void | start (const std::string &timing_name) |
Start measurement with a hint. | |
void | finish (const std::string &timing_name) |
Finish a measurement with a hint. | |
void | report () |
Write all timing information that has been recorded. | |
Protected Member Functions | |
void | write_report (std::ostream &s) |
Write the report to an output stream. | |
Protected Attributes | |
std::string | m_tool_name |
name of the tool we are timing | |
std::string | m_filename |
name of the file to write timings to | |
std::map< std::string, timing > | m_timings |
collection of timings | |
Simple timer to time the CPU time used by a piece of code.
Example usage: execution_timer timer("test_tool", "/path/to/file") timer.start("hint") ... (execute some code here) ... timer.finish("hint") timer.report()
This will output the following to the file "/path/to/file", or standard error if filename is empty, assuming that the time between start and finish is n seconds (with precision of 2 decimal places).
Note that this is an output format that can immediately be parsed using YAML (http://www.yaml.org/)
Definition at line 46 of file execution_timer.h.
|
inline |
Constructor of a simple execution timer.
[in] | tool_name | Name of the tool that does the measurements |
[in] | filename | Name of the file to which the measurements are written |
Definition at line 105 of file execution_timer.h.
|
inline |
Destructor.
Definition at line 111 of file execution_timer.h.
|
inline |
Finish a measurement with a hint.
[in] | timing_name | Name of the measurment being finished |
Definition at line 135 of file execution_timer.h.
|
inline |
Write all timing information that has been recorded.
Timing information is written to the filename that was provided in the constructor. If no filename was provided (i.e. the filename is empty) the information is written to standard error. The output is in YAML compatible format.
Definition at line 158 of file execution_timer.h.
|
inline |
Start measurement with a hint.
[in] | timing_name | Name of the measurement being started |
Definition at line 118 of file execution_timer.h.
|
inlineprotected |
Write the report to an output stream.
[in] | s | The output stream to which the report is written. |
Definition at line 71 of file execution_timer.h.
|
protected |
name of the file to write timings to
Definition at line 66 of file execution_timer.h.
|
protected |
collection of timings
Definition at line 67 of file execution_timer.h.
|
protected |
name of the tool we are timing
Definition at line 65 of file execution_timer.h.