Just to followup, I’ve been using a template method pattern-ish thing as a stopgap to track paint times on my components:
class MelatoninComponent : public juce::Component
{
public:
void paint (juce::Graphics& g) final
{
// Log start time here with juce::Time::getHighResolutionTicks()
timedPaint (g); // will calls the derived class' paintContent method
// Log end time here
}
protected:
// derived classes implement this
virtual void timedPaint (juce::Graphics& g) {}
};
class DerivedComponent : public MelatoninComponent
{
protected:
void timedPaint (juce::Graphics& g) override
{
// normal component painting stuff here
}
};
I hand-roll most components anyway, so they are already derived from MelatoninComponent
(which has additional features like padding, etc) and rename my paint
methods to timedPaint
. So this solution doesn’t work for juce::Components buried in stock widgets.
Would still love it if the JUCE team added some simple hooks (such as @RolandMR shared) in juce_Component.h
— a small addition with a lot of upside for JUCE tooling!