mirror of
https://github.com/f4exb/sdrangel.git
synced 2026-06-18 21:58:37 -04:00
Benchmarking: implemented decimator float to int test
This commit is contained in:
+96
-25
@@ -38,69 +38,140 @@ MainBench::~MainBench()
|
||||
|
||||
void MainBench::run()
|
||||
{
|
||||
QElapsedTimer timer;
|
||||
qint64 nsecs;
|
||||
|
||||
qDebug() << "MainBench::run: parameters:"
|
||||
<< " test: " << m_parser.getTest()
|
||||
qDebug() << "MainBench::run: parameters:"
|
||||
<< " testStr: " << m_parser.getTestStr()
|
||||
<< " testType: " << (int) m_parser.getTestType()
|
||||
<< " nsamples: " << m_parser.getNbSamples()
|
||||
<< " repet: " << m_parser.getRepetition()
|
||||
<< " log2f: " << m_parser.getLog2Factor();
|
||||
|
||||
qDebug() << "MainBench::run: create test data";
|
||||
|
||||
m_buf = new qint16[m_parser.getNbSamples()*2];
|
||||
if (m_parser.getTestType() == ParserBench::TestDecimatorsII) {
|
||||
testDecimateII();
|
||||
} else if (m_parser.getTestType() == ParserBench::TestDecimatorsFI) {
|
||||
testDecimateFI();
|
||||
}
|
||||
|
||||
emit finished();
|
||||
}
|
||||
|
||||
void MainBench::testDecimateII()
|
||||
{
|
||||
QElapsedTimer timer;
|
||||
qint64 nsecs;
|
||||
|
||||
qDebug() << "MainBench::testDecimateII: create test data";
|
||||
|
||||
qint16 *buf = new qint16[m_parser.getNbSamples()*2];
|
||||
m_convertBuffer.resize(m_parser.getNbSamples()/(1<<m_parser.getLog2Factor()));
|
||||
|
||||
qDebug() << "MainBench::run: run test";
|
||||
qDebug() << "MainBench::testDecimateII: run test";
|
||||
timer.start();
|
||||
|
||||
for (uint32_t i = 0; i < m_parser.getRepetition(); i++)
|
||||
{
|
||||
decimate(m_buf, m_parser.getNbSamples()*2);
|
||||
decimateII(buf, m_parser.getNbSamples()*2);
|
||||
}
|
||||
|
||||
nsecs = timer.nsecsElapsed();
|
||||
QDebug debug = qDebug();
|
||||
debug.noquote();
|
||||
debug << tr("MainBench::run: ran test in %L1 ns").arg(nsecs);
|
||||
debug << tr("MainBench::testDecimateII: ran test in %L1 ns").arg(nsecs);
|
||||
|
||||
|
||||
qDebug() << "MainBench::run: cleanup test data";
|
||||
qDebug() << "MainBench::testDecimateII: cleanup test data";
|
||||
|
||||
delete[] m_buf;
|
||||
|
||||
emit finished();
|
||||
delete[] buf;
|
||||
}
|
||||
|
||||
void MainBench::decimate(const qint16* buf, int len)
|
||||
void MainBench::testDecimateFI()
|
||||
{
|
||||
QElapsedTimer timer;
|
||||
qint64 nsecs;
|
||||
|
||||
qDebug() << "MainBench::testDecimateFI: create test data";
|
||||
|
||||
float *buf = new float[m_parser.getNbSamples()*2];
|
||||
m_convertBuffer.resize(m_parser.getNbSamples()/(1<<m_parser.getLog2Factor()));
|
||||
|
||||
qDebug() << "MainBench::testDecimateFI: run test";
|
||||
timer.start();
|
||||
|
||||
for (uint32_t i = 0; i < m_parser.getRepetition(); i++)
|
||||
{
|
||||
decimateFI(buf, m_parser.getNbSamples()*2);
|
||||
}
|
||||
|
||||
nsecs = timer.nsecsElapsed();
|
||||
QDebug debug = qDebug();
|
||||
debug.noquote();
|
||||
debug << tr("MainBench::testDecimateFI: ran test in %L1 ns").arg(nsecs);
|
||||
|
||||
|
||||
qDebug() << "MainBench::testDecimateFI: cleanup test data";
|
||||
|
||||
delete[] buf;
|
||||
}
|
||||
|
||||
void MainBench::decimateII(const qint16* buf, int len)
|
||||
{
|
||||
SampleVector::iterator it = m_convertBuffer.begin();
|
||||
|
||||
switch (m_parser.getLog2Factor())
|
||||
{
|
||||
case 0:
|
||||
m_decimators.decimate1(&it, buf, len);
|
||||
m_decimatorsII.decimate1(&it, buf, len);
|
||||
break;
|
||||
case 1:
|
||||
m_decimators.decimate2_cen(&it, buf, len);
|
||||
m_decimatorsII.decimate2_cen(&it, buf, len);
|
||||
break;
|
||||
case 2:
|
||||
m_decimators.decimate4_cen(&it, buf, len);
|
||||
m_decimatorsII.decimate4_cen(&it, buf, len);
|
||||
break;
|
||||
case 3:
|
||||
m_decimators.decimate8_cen(&it, buf, len);
|
||||
m_decimatorsII.decimate8_cen(&it, buf, len);
|
||||
break;
|
||||
case 4:
|
||||
m_decimators.decimate16_cen(&it, buf, len);
|
||||
m_decimatorsII.decimate16_cen(&it, buf, len);
|
||||
break;
|
||||
case 5:
|
||||
m_decimators.decimate32_cen(&it, buf, len);
|
||||
m_decimatorsII.decimate32_cen(&it, buf, len);
|
||||
break;
|
||||
case 6:
|
||||
m_decimators.decimate64_cen(&it, buf, len);
|
||||
m_decimatorsII.decimate64_cen(&it, buf, len);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainBench::decimateFI(const float *buf, int len)
|
||||
{
|
||||
SampleVector::iterator it = m_convertBuffer.begin();
|
||||
|
||||
switch (m_parser.getLog2Factor())
|
||||
{
|
||||
case 0:
|
||||
m_decimatorsFI.decimate1(&it, buf, len);
|
||||
break;
|
||||
case 1:
|
||||
m_decimatorsFI.decimate2_cen(&it, buf, len);
|
||||
break;
|
||||
case 2:
|
||||
m_decimatorsFI.decimate4_cen(&it, buf, len);
|
||||
break;
|
||||
case 3:
|
||||
m_decimatorsFI.decimate8_cen(&it, buf, len);
|
||||
break;
|
||||
case 4:
|
||||
m_decimatorsFI.decimate16_cen(&it, buf, len);
|
||||
break;
|
||||
case 5:
|
||||
m_decimatorsFI.decimate32_cen(&it, buf, len);
|
||||
break;
|
||||
case 6:
|
||||
m_decimatorsFI.decimate64_cen(&it, buf, len);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user