Add performance counter stats to status bar
This commit is contained in:
@ -67,11 +67,17 @@ Pane {
|
||||
}
|
||||
}
|
||||
|
||||
Label {
|
||||
ColumnLayout {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
|
||||
text: __controller.performance + ' FPS'
|
||||
Label {
|
||||
text: __controller.dmxFps + ' FPS'
|
||||
}
|
||||
|
||||
Label {
|
||||
text: __controller.computeMaxElapsed + "ms / " + __controller.dmxMaxElapsed + "ms"
|
||||
}
|
||||
}
|
||||
|
||||
Button {
|
||||
|
@ -1,11 +1,12 @@
|
||||
#include "dmxcontroller.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
//#include <unistd.h>
|
||||
//#include <sys/ioctl.h>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
#include <QMutexLocker>
|
||||
#include <QElapsedTimer>
|
||||
|
||||
#include "projectloader.h"
|
||||
|
||||
@ -344,6 +345,9 @@ void DmxController::sendDmxBuffer()
|
||||
|
||||
char buf[513] {0};
|
||||
|
||||
QElapsedTimer timer;
|
||||
timer.start();
|
||||
|
||||
{
|
||||
QMutexLocker locker{&m_mutex};
|
||||
|
||||
@ -414,6 +418,11 @@ void DmxController::sendDmxBuffer()
|
||||
}
|
||||
}
|
||||
|
||||
if (const auto elapsed = timer.elapsed(); elapsed > m_computeMaxElapsed)
|
||||
m_computeMaxElapsed = elapsed;
|
||||
|
||||
timer.restart();
|
||||
|
||||
m_serialPort.setBreakEnabled(true);
|
||||
QThread::usleep(88);
|
||||
m_serialPort.setBreakEnabled(false);
|
||||
@ -423,14 +432,27 @@ void DmxController::sendDmxBuffer()
|
||||
m_serialPort.flush();
|
||||
// qDebug("%lli written", written);
|
||||
|
||||
if (const auto elapsed = timer.elapsed(); elapsed > m_dmxMaxElapsed)
|
||||
m_dmxMaxElapsed = elapsed;
|
||||
|
||||
m_counter++;
|
||||
|
||||
if (m_lastInfo.msecsTo(now) >= 1000)
|
||||
{
|
||||
qInfo("%i per second", m_counter);
|
||||
m_lastCounter = m_counter;
|
||||
emit performanceChanged(m_counter);
|
||||
m_counter = 0;
|
||||
|
||||
m_lastInfo = now;
|
||||
|
||||
m_lastCounter = m_counter;
|
||||
emit dmxFpsChanged(m_counter);
|
||||
m_counter = 0;
|
||||
|
||||
m_lastDmxMaxElapsed = m_dmxMaxElapsed;
|
||||
emit dmxMaxElapsedChanged(m_lastDmxMaxElapsed);
|
||||
m_dmxMaxElapsed = 0;
|
||||
|
||||
m_lastComputeMaxElapsed = m_computeMaxElapsed;
|
||||
emit computeMaxElapsedChanged(m_lastComputeMaxElapsed);
|
||||
m_computeMaxElapsed = 0;
|
||||
}
|
||||
}
|
||||
|
@ -12,8 +12,10 @@
|
||||
class DmxController : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(int performance READ performance NOTIFY performanceChanged)
|
||||
Q_PROPERTY(ScheinCommanderSettings* settings READ settings CONSTANT)
|
||||
Q_PROPERTY(int dmxFps READ dmxFps NOTIFY dmxFpsChanged)
|
||||
Q_PROPERTY(int dmxMaxElapsed READ dmxMaxElapsed NOTIFY dmxMaxElapsedChanged)
|
||||
Q_PROPERTY(int computeMaxElapsed READ computeMaxElapsed NOTIFY computeMaxElapsedChanged)
|
||||
|
||||
public:
|
||||
explicit DmxController(ScheinCommanderSettings &settings, QObject *parent = nullptr);
|
||||
@ -41,11 +43,14 @@ public:
|
||||
|
||||
ScheinCommanderSettings *settings() { return &m_settings; }
|
||||
const ScheinCommanderSettings *settings() const { return &m_settings; }
|
||||
int performance() const { return m_lastCounter; }
|
||||
int dmxFps() const { return m_lastCounter; }
|
||||
int dmxMaxElapsed() const { return m_lastDmxMaxElapsed; }
|
||||
int computeMaxElapsed() const { return m_lastComputeMaxElapsed; }
|
||||
|
||||
signals:
|
||||
void needToAskWhereToSaveChanged(bool needToAskWhereToSave);
|
||||
void performanceChanged(int performance);
|
||||
void dmxFpsChanged(int dmxFps);
|
||||
void dmxMaxElapsedChanged(int dmxMaxElapsed);
|
||||
void computeMaxElapsedChanged(int computeMaxElapsed);
|
||||
|
||||
void deviceTypeInserted(int first, int last);
|
||||
void deviceTypeRemoved(int first, int last);
|
||||
@ -89,4 +94,8 @@ private:
|
||||
QDateTime m_lastInfo;
|
||||
int m_counter;
|
||||
std::atomic<int> m_lastCounter;
|
||||
int m_dmxMaxElapsed{};
|
||||
std::atomic<int> m_lastDmxMaxElapsed;
|
||||
int m_computeMaxElapsed{};
|
||||
std::atomic<int> m_lastComputeMaxElapsed;
|
||||
};
|
||||
|
Reference in New Issue
Block a user