Paste P138

Masterwork From Distant Lands
ActivePublic

Authored by dkazakov on Nov 23 2017, 11:10 AM.
diff --git a/libs/global/kis_relaxed_timer.cpp b/libs/global/kis_relaxed_timer.cpp
index 00b3691..dfe3f4e 100644
--- a/libs/global/kis_relaxed_timer.cpp
+++ b/libs/global/kis_relaxed_timer.cpp
@@ -97,6 +97,7 @@ void KisRelaxedTimer::resync()
m_emitOnTimeTick = m_nextTimerTickSeqNo;
m_timer.start(m_interval, this);
m_tick.start();
+ m_numberOfRestarts++;
}
void KisRelaxedTimer::timerEvent(QTimerEvent *event)
diff --git a/libs/global/kis_relaxed_timer.h b/libs/global/kis_relaxed_timer.h
index 08ca7e7..20a0d7b 100644
--- a/libs/global/kis_relaxed_timer.h
+++ b/libs/global/kis_relaxed_timer.h
@@ -64,6 +64,8 @@ public:
int remainingTime() const;
+ int m_numberOfRestarts = 0;
+
Q_SIGNALS:
void timeout();
diff --git a/libs/global/kis_signal_compressor.cpp b/libs/global/kis_signal_compressor.cpp
index 90e5614..2c4dabb 100644
--- a/libs/global/kis_signal_compressor.cpp
+++ b/libs/global/kis_signal_compressor.cpp
@@ -47,6 +47,11 @@ void KisSignalCompressor::setDelay(int delay)
m_timer->setInterval(delay, 1, delay / 10);
}
+int KisSignalCompressor::numRestarts() const
+{
+ return m_timer->m_numberOfRestarts;
+}
+
void KisSignalCompressor::start()
{
Q_ASSERT(m_mode != UNDEFINED);
diff --git a/libs/global/kis_signal_compressor.h b/libs/global/kis_signal_compressor.h
index ff2ff7a..33f23eb 100644
--- a/libs/global/kis_signal_compressor.h
+++ b/libs/global/kis_signal_compressor.h
@@ -74,6 +74,8 @@ public:
void setMode(Mode mode);
void setDelay(int delay);
+ int numRestarts() const;
+
public Q_SLOTS:
void start();
void stop();
diff --git a/libs/global/tests/CMakeLists.txt b/libs/global/tests/CMakeLists.txt
index 3cc4776..717ae1b 100644
--- a/libs/global/tests/CMakeLists.txt
+++ b/libs/global/tests/CMakeLists.txt
@@ -6,3 +6,8 @@ macro_add_unittest_definitions()
ecm_add_test(KisSharedThreadPoolAdapterTest.cpp
TEST_NAME KisSharedThreadPoolAdapter
LINK_LIBRARIES kritaglobal Qt5::Test)
+
+ecm_add_test(KisSignalCompressorTest.cpp
+ TEST_NAME KisSignalCompressorTest
+ LINK_LIBRARIES kritaglobal Qt5::Test)
+
diff --git a/libs/global/tests/KisSignalCompressorTest.cpp b/libs/global/tests/KisSignalCompressorTest.cpp
index 26dcc79..3e9f8df 100644
--- a/libs/global/tests/KisSignalCompressorTest.cpp
+++ b/libs/global/tests/KisSignalCompressorTest.cpp
@@ -93,6 +93,10 @@ public:
return min(m_negativeOffsetAccumulator);
}
+ int realNumberOfTicks() const {
+ return m_realNumberOfTicks;
+ }
+
void start() {
m_timeSinceLastTick.start();
m_timer.start(m_distribution(m_rnd));
@@ -129,6 +133,7 @@ private Q_SLOTS:
void timerTick() {
emit sigStartExternalTimer();
m_timer.start(m_distribution(m_rnd));
+ m_realNumberOfTicks++;
}
private:
@@ -138,6 +143,7 @@ private:
int m_desiredPeriod;
int m_desiredVariance;
int m_desiredNumEvents;
+ int m_realNumberOfTicks = 0;
QElapsedTimer m_timeSinceLastTick;
accumulator_set<qreal, stats<tag::mean, tag::lazy_variance, tag::min, tag::max> > m_accumulator;
@@ -177,6 +183,8 @@ void KisSignalCompressorTest::test()
qDebug() << " -offset: mean:" << tester.negativeOffsetMean()
<< "max:" << tester.negativeOffsetMax();
+
+ qDebug() << "Ticks:" << tester.realNumberOfTicks() << "Restarts:" << compressor.numRestarts() << qreal(compressor.numRestarts()) / tester.realNumberOfTicks();
}
QTEST_MAIN(KisSignalCompressorTest)
dkazakov edited the content of this paste. (Show Details)Nov 23 2017, 11:10 AM
dkazakov changed the title of this paste from untitled to Masterwork From Distant Lands.
dkazakov updated the paste's language from autodetect to autodetect.