Audacity 3.2.0
Classes | Public Types | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
FrameStatistics Class Referencefinal

A class to profile TrackPanel painting. More...

#include <FrameStatistics.h>

Collaboration diagram for FrameStatistics:
[legend]

Classes

class  Section
 Profiling section data. More...
 
class  Stopwatch
 RAII wrapper used to measure a section time. More...
 
struct  UpdatePublisher
 A helper that notifies the view that a specific section has changed. More...
 

Public Types

enum class  SectionID {
  TrackPanel , WaveformView , WaveDataCache , WaveBitmapCachePreprocess ,
  WaveBitmapCache , Count
}
 ID of the profiling section. More...
 
using Clock = std::chrono::high_resolution_clock
 
using Duration = Clock::duration
 
using Timepoint = Clock::time_point
 

Static Public Member Functions

static Stopwatch CreateStopwatch (SectionID section) noexcept
 Create a Stopwatch for the section specified. More...
 
static const SectionGetSection (SectionID section) noexcept
 Get the section data. More...
 
static Observer::Subscription Subscribe (UpdatePublisher::Callback callback)
 Subscribe to sections update. More...
 

Private Member Functions

void AddEvent (SectionID section, Duration duration)
 

Private Attributes

Section mSections [size_t(SectionID::Count)]
 
UpdatePublisher mUpdatePublisher
 

Detailed Description

A class to profile TrackPanel painting.


Audacity: A Digital Audio Editor

FrameStatistics.h

Dmitry Vedenko

Object of this class is a global singleton. If there are multiple opened projects, the statistics will be merged.

Definition at line 25 of file FrameStatistics.h.

Member Typedef Documentation

◆ Clock

using FrameStatistics::Clock = std::chrono::high_resolution_clock

Definition at line 28 of file FrameStatistics.h.

◆ Duration

using FrameStatistics::Duration = Clock::duration

Definition at line 29 of file FrameStatistics.h.

◆ Timepoint

using FrameStatistics::Timepoint = Clock::time_point

Definition at line 30 of file FrameStatistics.h.

Member Enumeration Documentation

◆ SectionID

enum class FrameStatistics::SectionID
strong

ID of the profiling section.

Enumerator
TrackPanel 

Full repaint time of the TrackPanel.

WaveformView 

Time required to draw a single clip.

WaveDataCache 

Time required to access the data cache.

WaveBitmapCachePreprocess 

Time required to build the structures required for the bitmap cache population.

WaveBitmapCache 

Time required to access the wave bitmaps cache.

Count 

Number of the sections.

Definition at line 33 of file FrameStatistics.h.

34 {
40 WaveDataCache,
42 WaveBitmapCachePreprocess,
44 WaveBitmapCache,
46 Count
47 };
The TrackPanel class coordinates updates and operations on the main part of the screen which contains...
Definition: TrackPanel.h:63
size_t Count(const Ptr< Type, BaseDeleter > &p)
Find out how many elements were allocated with a Ptr.
Definition: PackedArray.h:143

Member Function Documentation

◆ AddEvent()

void FrameStatistics::AddEvent ( SectionID  section,
Duration  duration 
)
private

Definition at line 121 of file FrameStatistics.cpp.

122{
123 if (section < SectionID::Count)
124 {
125 GetInstance().mSections[size_t(section)].AddEvent(duration);
127 }
128}
void AddEvent(Duration duration) noexcept
@ Count
Number of the sections.
UpdatePublisher mUpdatePublisher
Section mSections[size_t(SectionID::Count)]
FrameStatistics & GetInstance() noexcept

References FrameStatistics::Section::AddEvent(), Count, anonymous_namespace{FrameStatistics.cpp}::GetInstance(), FrameStatistics::UpdatePublisher::Invoke(), mSections, and mUpdatePublisher.

Referenced by FrameStatistics::Stopwatch::~Stopwatch().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CreateStopwatch()

FrameStatistics::Stopwatch FrameStatistics::CreateStopwatch ( SectionID  section)
staticnoexcept

Create a Stopwatch for the section specified.

Definition at line 89 of file FrameStatistics.cpp.

90{
91 // New frame has started
92 if (section == SectionID::TrackPanel)
93 {
94 auto& instance = GetInstance();
95
96 instance.mSections[size_t(SectionID::WaveformView)] = {};
97 instance.mSections[size_t(SectionID::WaveDataCache)] = {};
98 instance.mSections[size_t(SectionID::WaveBitmapCachePreprocess)] = {};
99 instance.mSections[size_t(SectionID::WaveBitmapCache)] = {};
100 }
101
102 return Stopwatch(section);
103}
@ WaveformView
Time required to draw a single clip.
@ WaveBitmapCachePreprocess
Time required to build the structures required for the bitmap cache population.
@ TrackPanel
Full repaint time of the TrackPanel.
@ WaveDataCache
Time required to access the data cache.
@ WaveBitmapCache
Time required to access the wave bitmaps cache.

References anonymous_namespace{FrameStatistics.cpp}::GetInstance(), TrackPanel, WaveBitmapCache, WaveBitmapCachePreprocess, WaveDataCache, and WaveformView.

Referenced by anonymous_namespace{WaveformView.cpp}::DrawClipWaveform(), and TrackPanel::OnPaint().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetSection()

const FrameStatistics::Section & FrameStatistics::GetSection ( SectionID  section)
staticnoexcept

Get the section data.

Definition at line 106 of file FrameStatistics.cpp.

107{
108 if (section < SectionID::Count)
109 return GetInstance().mSections[size_t(section)];
110
111 static Section fakeSection;
112 return fakeSection;
113}
constexpr auto Section
Definition: MenuRegistry.h:436

References Count, anonymous_namespace{FrameStatistics.cpp}::GetInstance(), and mSections.

Referenced by anonymous_namespace{FrameStatisticsDialog.cpp}::Dialog::SectionUpdated().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Subscribe()

Observer::Subscription FrameStatistics::Subscribe ( UpdatePublisher::Callback  callback)
static

Subscribe to sections update.

Definition at line 116 of file FrameStatistics.cpp.

117{
118 return GetInstance().mUpdatePublisher.Subscribe(std::move(callback));
119}
Subscription Subscribe(Callback callback)
Connect a callback to the Publisher; later-connected are called earlier.
Definition: Observer.h:199

References anonymous_namespace{FrameStatistics.cpp}::GetInstance(), mUpdatePublisher, and Observer::Publisher< Message, NotifyAll >::Subscribe().

Referenced by anonymous_namespace{FrameStatisticsDialog.cpp}::Dialog::Dialog().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ mSections

Section FrameStatistics::mSections[size_t(SectionID::Count)]
private

Definition at line 112 of file FrameStatistics.h.

Referenced by AddEvent(), and GetSection().

◆ mUpdatePublisher

UpdatePublisher FrameStatistics::mUpdatePublisher
private

Definition at line 114 of file FrameStatistics.h.

Referenced by AddEvent(), and Subscribe().


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