JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
juce::PerformanceCounter Class Reference

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.
 
 ~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.
 

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();
pc.stop();
}
A timer for measuring performance of code and dumping the results to a file.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
Definition juce_Memory.h:88

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.

@tags{Core}

Definition at line 49 of file juce_PerformanceCounter.h.

Constructor & Destructor Documentation

◆ PerformanceCounter()

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

Creates a PerformanceCounter object.

Parameters
counterNamethe name used when printing out the statistics
runsPerPrintoutthe number of start/stop iterations before calling printStatistics()
loggingFilea 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.

◆ ~PerformanceCounter()

juce::PerformanceCounter::~PerformanceCounter ( )

Destructor.

Definition at line 44 of file juce_PerformanceCounter.cpp.

Member Function Documentation

◆ getStatisticsAndReset()

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.

◆ 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.

◆ start()

void juce::PerformanceCounter::start ( )
noexcept

Starts timing.

See also
stop

Definition at line 97 of file juce_PerformanceCounter.cpp.

◆ 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

Definition at line 102 of file juce_PerformanceCounter.cpp.


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