Loading...
Searching...
No Matches
juce::PerformanceCounter Class Reference

## Detailed Description

A timer for measuring performance of code and dumping the results to a file.

e.g.

PerformanceCounter pc ("fish", 50, "/temp/myfishlog.txt");
for (;;)
{
pc.start();
doSomethingFishy();
pc.stop();
}
juce::PerformanceCounter::PerformanceCounter
PerformanceCounter(const String &counterName, int runsPerPrintout=100, const File &loggingFile=File())
Creates a PerformanceCounter object.

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.

The documentation for this class was generated from the following file:

- juce_core/time/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.
| ~PerformanceCounter ()
| Destructor.
void | start () noexcept
| Starts timing.
bool | stop ()
| Stops timing and prints out the results.
void | printStatistics ()
| Dumps the current metrics to the debugger output and to a file.
Statistics | getStatisticsAndReset ()
| Returns a copy of the current stats, and resets the internal counter.

## Constructors and Destructors

## PerformanceCounter()

juce::PerformanceCounter::PerformanceCounter | ( | const String & | counterName,
|  | int | runsPerPrintout = 100,
|  | const File & | loggingFile = File() )

Creates a PerformanceCounter object.

Parameters

  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

Referenced by getStatisticsAndReset().

## ~PerformanceCounter()

juce::PerformanceCounter::~PerformanceCounter | ( |  | ) |

Destructor.

## Member Functions

## start()

void juce::PerformanceCounter::start | ( |  | ) |

noexcept

Starts timing.

See also
  stop

## stop()

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.

See also
  start

References stop().

Referenced by stop().

## 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).

References printStatistics().

Referenced by printStatistics().

## getStatisticsAndReset()

Statistics juce::PerformanceCounter::getStatisticsAndReset | ( |  | ) |

Returns a copy of the current stats, and resets the internal counter.

References getStatisticsAndReset(), JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR, and PerformanceCounter().

Referenced by getStatisticsAndReset().

### Purchase

Get JUCE

### Discover

What's New in JUCE Features

### Learn

Documentaion Tutorials Made with JUCE Resources

### Support

JUCE Forum Newsletter Archive

### About

Contact Us JUCE Legal JUCE Licensing FAQ

### Events

Audio Developer Conference
© Raw Material Software Limited