From bdd685c63e3294f84698c80665b9e2d5a0f13407 Mon Sep 17 00:00:00 2001 From: f4exb Date: Tue, 21 May 2019 21:18:49 +0200 Subject: [PATCH] TestSource: debug message for QTimer --- .../testsource/testsourcethread.cpp | 23 ++++++++++++++++++- .../testsource/testsourcethread.h | 5 ++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/plugins/samplesource/testsource/testsourcethread.cpp b/plugins/samplesource/testsource/testsourcethread.cpp index e16c4a85c..1df45e022 100644 --- a/plugins/samplesource/testsource/testsourcethread.cpp +++ b/plugins/samplesource/testsource/testsourcethread.cpp @@ -63,7 +63,8 @@ TestSourceThread::TestSourceThread(SampleSinkFifo* sampleFifo, QObject* parent) m_fcPosShift(0), m_throttlems(TESTSOURCE_THROTTLE_MS), m_throttleToggle(false), - m_mutex(QMutex::Recursive) + m_mutex(QMutex::Recursive), + m_histoCounter(0) { connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()), Qt::QueuedConnection); } @@ -74,6 +75,7 @@ TestSourceThread::~TestSourceThread() void TestSourceThread::startWork() { + //m_timer.setTimerType(Qt::PreciseTimer); connect(&m_timer, SIGNAL(timeout()), this, SLOT(tick())); m_timer.start(50); m_startWaitMutex.lock(); @@ -392,6 +394,25 @@ void TestSourceThread::tick() { qint64 throttlems = m_elapsedTimer.restart(); + std::map::iterator it; + it = m_timerHistogram.find(throttlems); + + if (it == m_timerHistogram.end()) { + m_timerHistogram[throttlems] = 1; + } else { + it->second++; + } + + if (m_histoCounter < 49) { + m_histoCounter++; + } else { + qDebug("TestSourceThread::tick: -----------"); + for (std::map::iterator it = m_timerHistogram.begin(); it != m_timerHistogram.end(); ++it) { + qDebug("TestSourceThread::tick: %d: %d", it->first, it->second); + } + m_histoCounter = 0; + } + if ((throttlems > 45) && (throttlems < 55) && (throttlems != m_throttlems)) { QMutexLocker mutexLocker(&m_mutex); diff --git a/plugins/samplesource/testsource/testsourcethread.h b/plugins/samplesource/testsource/testsourcethread.h index 309a08dc6..110013fbe 100644 --- a/plugins/samplesource/testsource/testsourcethread.h +++ b/plugins/samplesource/testsource/testsourcethread.h @@ -18,6 +18,8 @@ #ifndef _TESTSOURCE_TESTSOURCETHREAD_H_ #define _TESTSOURCE_TESTSOURCETHREAD_H_ +#include + #include #include #include @@ -133,6 +135,9 @@ private: Decimators m_decimators_12; Decimators m_decimators_16; + std::map m_timerHistogram; + uint32_t m_histoCounter; + void startWork(); void stopWork(); void run();