Loading...
Searching...
No Matches
juce_AudioProcessLoadMeasurer.h
/*
==============================================================================
This file is part of the JUCE library.
Copyright (c) 2022 - Raw Material Software Limited
JUCE is an open source library subject to commercial or open-source
licensing.
The code included in this file is provided under the terms of the ISC license
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
To use, copy, modify, and/or distribute this software for any purpose with or
without fee is hereby granted provided that the above copyright notice and
this permission notice appear in all copies.
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
DISCLAIMED.
==============================================================================
*/
namespace juce
{
//==============================================================================
class JUCE_API AudioProcessLoadMeasurer
{
public:
AudioProcessLoadMeasurer();
~AudioProcessLoadMeasurer();
//==============================================================================
void reset();
void reset (double sampleRate, int blockSize);
double getLoadAsProportion() const;
double getLoadAsPercentage() const;
int getXRunCount() const;
//==============================================================================
struct JUCE_API ScopedTimer
{
ScopedTimer (AudioProcessLoadMeasurer&);
ScopedTimer (AudioProcessLoadMeasurer&, int numSamplesInBlock);
~ScopedTimer();
private:
AudioProcessLoadMeasurer& owner;
double startTime;
int samplesInBlock;
JUCE_DECLARE_NON_COPYABLE (ScopedTimer)
};
void registerBlockRenderTime (double millisecondsTaken);
void registerRenderTime (double millisecondsTaken, int numSamples);
private:
void registerRenderTimeLocked (double, int);
SpinLock mutex;
int samplesPerBlock = 0;
double msPerSample = 0;
std::atomic<double> cpuUsageProportion { 0 };
std::atomic<int> xruns { 0 };
};
} // namespace juce
juce::AudioProcessLoadMeasurer::~AudioProcessLoadMeasurer
~AudioProcessLoadMeasurer()
juce::AudioProcessLoadMeasurer::getLoadAsPercentage
double getLoadAsPercentage() const
Definition juce_AudioProcessLoadMeasurer.cpp:77
juce::AudioProcessLoadMeasurer::registerBlockRenderTime
void registerBlockRenderTime(double millisecondsTaken)
Definition juce_AudioProcessLoadMeasurer.cpp:45
juce::AudioProcessLoadMeasurer::registerRenderTime
void registerRenderTime(double millisecondsTaken, int numSamples)
Definition juce_AudioProcessLoadMeasurer.cpp:53
juce::AudioProcessLoadMeasurer::getXRunCount
int getXRunCount() const
Definition juce_AudioProcessLoadMeasurer.cpp:79
juce::AudioProcessLoadMeasurer::reset
void reset()
Definition juce_AudioProcessLoadMeasurer.cpp:29
juce::AudioProcessLoadMeasurer::getLoadAsProportion
double getLoadAsProportion() const
Definition juce_AudioProcessLoadMeasurer.cpp:76
juce::SpinLock
Definition juce_SpinLock.h:42