OpenShot Library | OpenShotAudio
0.2.2
|
A timer for measuring performance of code and dumping the results to a file. More...
#include <juce_PerformanceCounter.h>
Classes | |
struct | Statistics |
Holds the current statistics. More... | |
Public Member Functions | |
PerformanceCounter (const String &counterName, int runsPerPrintout=100, const File &loggingFile=File()) | |
Creates a PerformanceCounter object. More... | |
~PerformanceCounter () | |
Destructor. More... | |
void | start () noexcept |
Starts timing. More... | |
bool | stop () |
Stops timing and prints out the results. More... | |
void | printStatistics () |
Dumps the current metrics to the debugger output and to a file. More... | |
Statistics | getStatisticsAndReset () |
Returns a copy of the current stats, and resets the internal counter. More... | |
A timer for measuring performance of code and dumping the results to a file.
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 printed to a file every 50 times round the loop.
Definition at line 53 of file juce_PerformanceCounter.h.
juce::PerformanceCounter::PerformanceCounter | ( | const String & | counterName, |
int | runsPerPrintout = 100 , |
||
const File & | loggingFile = File() |
||
) |
Creates a PerformanceCounter object.
counterName | the name used when printing out the statistics |
runsPerPrintout | the number of start/stop iterations before calling printStatistics() |
loggingFile | a file to dump the results to - if this is File(), the results are just written to the debugger output |
Definition at line 37 of file juce_PerformanceCounter.cpp.
References juce::Time::getCurrentTime().
juce::PerformanceCounter::~PerformanceCounter | ( | ) |
Destructor.
Definition at line 44 of file juce_PerformanceCounter.cpp.
References printStatistics(), and juce::MemoryOutputStream::toString().
|
noexcept |
Starts timing.
Definition at line 97 of file juce_PerformanceCounter.cpp.
References juce::Time::getHighResolutionTicks().
bool juce::PerformanceCounter::stop | ( | ) |
Stops timing and prints out the results.
The number of iterations before doing a printout of the results is set in the constructor.
Definition at line 102 of file juce_PerformanceCounter.cpp.
References juce::Time::getHighResolutionTicks(), juce::Time::highResolutionTicksToSeconds(), and printStatistics().
void juce::PerformanceCounter::printStatistics | ( | ) |
Dumps the current metrics to the debugger output and to a file.
As well as using Logger::outputDebugString to print the results, this will write then to the file specified in the constructor (if this was valid).
Definition at line 113 of file juce_PerformanceCounter.cpp.
References getStatisticsAndReset(), and juce::Logger::outputDebugString().
Referenced by stop(), and ~PerformanceCounter().
PerformanceCounter::Statistics juce::PerformanceCounter::getStatisticsAndReset | ( | ) |
Returns a copy of the current stats, and resets the internal counter.
Definition at line 121 of file juce_PerformanceCounter.cpp.
Referenced by printStatistics().