Add FPS counter

This commit is contained in:
2023-02-18 15:55:25 +01:00
parent 2daafde7f2
commit 4da6ad7d28
3 changed files with 16 additions and 0 deletions

View File

@ -39,6 +39,13 @@ Pane {
} }
} }
Label {
Layout.fillWidth: true
Layout.fillHeight: true
text: __controller.performance + ' FPS'
}
Button { Button {
Layout.fillHeight: true Layout.fillHeight: true

View File

@ -149,6 +149,8 @@ void DmxController::sendDmxBuffer()
if (m_lastInfo.msecsTo(now) >= 1000) if (m_lastInfo.msecsTo(now) >= 1000)
{ {
qInfo("%i per second", m_counter); qInfo("%i per second", m_counter);
m_lastCounter = m_counter;
emit performanceChanged(m_counter);
m_counter = 0; m_counter = 0;
m_lastInfo = now; m_lastInfo = now;
} }

View File

@ -11,6 +11,7 @@
class DmxController : public QObject class DmxController : public QObject
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(int performance READ performance NOTIFY performanceChanged)
public: public:
explicit DmxController(QObject *parent = nullptr); explicit DmxController(QObject *parent = nullptr);
@ -24,6 +25,11 @@ public:
QReadWriteLock &projectLock() { return m_projectLock; } QReadWriteLock &projectLock() { return m_projectLock; }
int performance() const { return m_lastCounter; }
signals:
void performanceChanged(int performance);
protected: protected:
friend class DmxControllerThread; friend class DmxControllerThread;
@ -41,4 +47,5 @@ private:
QDateTime m_lastInfo; QDateTime m_lastInfo;
int m_counter; int m_counter;
std::atomic<int> m_lastCounter;
}; };