PicoScenes API Docs
 
Loading...
Searching...
No Matches
DSPRateTracker.hxx
Go to the documentation of this file.
1//
2// Created by Zhiping Jiang on 5/16/21.
3//
4
5#ifndef PICOSCENES_PLATFORM_DSPRATETRACKER_HXX
6#define PICOSCENES_PLATFORM_DSPRATETRACKER_HXX
7
8#include <chrono>
9#include "LoggingService.hxx"
10
18class [[maybe_unused]] DSPRateTracker {
19public:
29 static std::shared_ptr<DSPRateTracker> getInstance(const std::string &trackerName);
30
36 DSPRateTracker() = delete;
37
43 void reset();
44
52 [[maybe_unused]] void tick(double numSignals);
53
59 [[maybe_unused]] void tock();
60
66 [[maybe_unused]] [[nodiscard]] double getProcessingRate() const;
67
73 [[maybe_unused]] [[nodiscard]] std::string getDisplayString() const;
74
75private:
76 explicit DSPRateTracker(const std::string &trackerName);
77
78 std::string trackerName;
79 double signalCount = 0;
80 std::chrono::system_clock::time_point tickTime;
81 double processingTime = 0;
82 double processingRate = 0;
83
84};
85
86
87#endif //PICOSCENES_PLATFORM_DSPRATETRACKER_HXX
Class for tracking and measuring DSP processing rates.
static std::shared_ptr< DSPRateTracker > getInstance(const std::string &trackerName)
Get instance of rate tracker for specific name.
double getProcessingRate() const
Get current processing rate.
std::string getDisplayString() const
Get formatted string describing processing rate.
void tick(double numSignals)
Start timing for a processing operation.
DSPRateTracker()=delete
Default constructor (deleted)
void tock()
End timing for a processing operation.
void reset()
Reset tracker statistics.