|
TracktionEngine
|
A timer for measuring performance of code. More...
#include <tracktion_PerformanceMeasurement.h>
Classes | |
| struct | Statistics |
| Holds the current statistics. More... | |
Public Member Functions | |
| PerformanceMeasurement (std::string counterName, int runsPerPrintout=100, bool printOnDestruction=true) | |
| Creates a PerformanceMeasurement object. | |
| ~PerformanceMeasurement () | |
| Destructor. | |
| void | start () noexcept |
| Starts timing. | |
| bool | stop () |
| Stops timing and prints out the results. | |
| void | printStatistics () |
| Dumps the current metrics to std::cout. | |
| std::string | getName () const |
| Returns the name. | |
| Statistics | getStatistics () const |
| Returns a copy of the current stats. | |
| Statistics | getStatisticsAndReset () |
| Returns a copy of the current stats, and resets the internal counter. | |
A timer for measuring performance of code.
e.g.
In this example, the time of each period between calling start/stop will be measured and averaged over 50 runs, and the results logged to std::cout every 50 times round the loop.
| tracktion::graph::PerformanceMeasurement::PerformanceMeasurement | ( | std::string | counterName, |
| int | runsPerPrintout = 100, |
||
| bool | printOnDestruction = true |
||
| ) |
Creates a PerformanceMeasurement object.
| counterName | the name used when printing out the statistics |
| runsPerPrintout | the number of start/stop iterations before calling printStatistics() |
| tracktion::graph::PerformanceMeasurement::~PerformanceMeasurement | ( | ) |
Destructor.
References tracktion::graph::PerformanceMeasurement::Statistics::numRuns, and printStatistics().
|
noexcept |
Starts timing.
| bool tracktion::graph::PerformanceMeasurement::stop | ( | ) |
Stops timing and prints out the results.
The number of iterations before doing a printout of the results is set in the constructor.
References tracktion::graph::PerformanceMeasurement::Statistics::addResult(), tracktion::graph::PerformanceMeasurement::Statistics::numRuns, and printStatistics().
| void tracktion::graph::PerformanceMeasurement::printStatistics | ( | ) |
Dumps the current metrics to std::cout.
References getStatisticsAndReset(), and tracktion::graph::PerformanceMeasurement::Statistics::toString().
Referenced by stop(), and ~PerformanceMeasurement().
| std::string tracktion::graph::PerformanceMeasurement::getName | ( | ) | const |
Returns the name.
Referenced by tracktion::engine::benchmark_utilities::prepareRenderAndDestroy().
| PerformanceMeasurement::Statistics tracktion::graph::PerformanceMeasurement::getStatistics | ( | ) | const |
Returns a copy of the current stats.
| PerformanceMeasurement::Statistics tracktion::graph::PerformanceMeasurement::getStatisticsAndReset | ( | ) |
Returns a copy of the current stats, and resets the internal counter.
References tracktion::graph::PerformanceMeasurement::Statistics::clear().
Referenced by printStatistics().