mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 17:35:34 +08:00
Performance samples as discussed:
* Vector vs List * getByCallsign.getTimeBefore vs. getTimeBefore.getByCallsign
This commit is contained in:
@@ -43,10 +43,11 @@ int main(int argc, char *argv[])
|
|||||||
qtout << "3 .. Containers" << endl;
|
qtout << "3 .. Containers" << endl;
|
||||||
qtout << "4 .. Metadata" << endl;
|
qtout << "4 .. Metadata" << endl;
|
||||||
qtout << "5 .. Variant" << endl;
|
qtout << "5 .. Variant" << endl;
|
||||||
qtout << "6 .. Performance" << endl;
|
qtout << "6a .. Performance create / copy / ..." << endl;
|
||||||
|
qtout << "6b .. 25/100 Performance impl. type ..." << endl;
|
||||||
|
qtout << "6c .. 25/20 Performance impl. type ..." << endl;
|
||||||
qtout << "7 .. Algorithms" << endl;
|
qtout << "7 .. Algorithms" << endl;
|
||||||
qtout << "8 .. Concurrent (thread)" << endl;
|
qtout << "8 .. Concurrent (thread)" << endl;
|
||||||
|
|
||||||
qtout << "-----" << endl;
|
qtout << "-----" << endl;
|
||||||
qtout << "x .. Bye" << endl;
|
qtout << "x .. Bye" << endl;
|
||||||
QString s = qtin.readLine().toLower().trimmed();
|
QString s = qtin.readLine().toLower().trimmed();
|
||||||
@@ -56,7 +57,9 @@ int main(int argc, char *argv[])
|
|||||||
else if (s.startsWith("3")) { CSamplesContainer::samples(); }
|
else if (s.startsWith("3")) { CSamplesContainer::samples(); }
|
||||||
else if (s.startsWith("4")) { CSamplesMetadata::samples(); }
|
else if (s.startsWith("4")) { CSamplesMetadata::samples(); }
|
||||||
else if (s.startsWith("5")) { CSamplesVariant::samples(); }
|
else if (s.startsWith("5")) { CSamplesVariant::samples(); }
|
||||||
else if (s.startsWith("6")) { CSamplesPerformance::samples(qtout); }
|
else if (s.startsWith("6a")) { CSamplesPerformance::samplesMisc(qtout); }
|
||||||
|
else if (s.startsWith("6b")) { CSamplesPerformance::samplesImplementationType(qtout, 25, 100); }
|
||||||
|
else if (s.startsWith("6c")) { CSamplesPerformance::samplesImplementationType(qtout, 25, 20); }
|
||||||
else if (s.startsWith("7")) { CSamplesAlgorithm::samples(); }
|
else if (s.startsWith("7")) { CSamplesAlgorithm::samples(); }
|
||||||
else if (s.startsWith("8")) { CSamplesConcurrent::samples(s, qtout, qtin); }
|
else if (s.startsWith("8")) { CSamplesConcurrent::samples(s, qtout, qtin); }
|
||||||
else if (s.startsWith("x")) { break; }
|
else if (s.startsWith("x")) { break; }
|
||||||
|
|||||||
@@ -8,9 +8,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "samplesperformance.h"
|
#include "samplesperformance.h"
|
||||||
|
#include "blackmisc/avaircraftsituationlist.h"
|
||||||
|
#include "blackmisc/coordinategeodetic.h"
|
||||||
|
#include "blackmisc/avaltitude.h"
|
||||||
#include "blackmisc/testing.h"
|
#include "blackmisc/testing.h"
|
||||||
|
|
||||||
using namespace BlackMisc::Aviation;
|
using namespace BlackMisc::Aviation;
|
||||||
|
using namespace BlackMisc::Geo;
|
||||||
|
using namespace BlackMisc::PhysicalQuantities;
|
||||||
|
|
||||||
namespace BlackMiscTest
|
namespace BlackMiscTest
|
||||||
{
|
{
|
||||||
@@ -18,7 +23,7 @@ namespace BlackMiscTest
|
|||||||
/*
|
/*
|
||||||
* Samples
|
* Samples
|
||||||
*/
|
*/
|
||||||
int CSamplesPerformance::samples(QTextStream &out)
|
int CSamplesPerformance::samplesMisc(QTextStream &out)
|
||||||
{
|
{
|
||||||
QTime timer;
|
QTime timer;
|
||||||
int ms, number;
|
int ms, number;
|
||||||
@@ -147,4 +152,98 @@ namespace BlackMiscTest
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CSamplesPerformance::samplesImplementationType(QTextStream &out, int numberOfCallsigns, int numberOfTimes)
|
||||||
|
{
|
||||||
|
const QDateTime baseTime = QDateTime::currentDateTimeUtc();
|
||||||
|
const qint64 baseTimeEpoch = baseTime.toMSecsSinceEpoch();
|
||||||
|
CAircraftSituationList situations;
|
||||||
|
|
||||||
|
for (int cs = 0; cs < numberOfCallsigns; cs++)
|
||||||
|
{
|
||||||
|
CCallsign callsign("CS" + QString::number(cs));
|
||||||
|
CCoordinateGeodetic coordinate(cs, cs, cs);
|
||||||
|
CAltitude alt(cs, CAltitude::MeanSeaLevel, CLengthUnit::m());
|
||||||
|
for (int t = 0; t < numberOfTimes; t++)
|
||||||
|
{
|
||||||
|
CAircraftSituation s(callsign, coordinate, alt);
|
||||||
|
s.setMSecsSinceEpoch(baseTimeEpoch + 10 * t);
|
||||||
|
situations.push_back(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QTime timer;
|
||||||
|
out << "Created " << situations.size() << " situations" << endl;
|
||||||
|
|
||||||
|
timer.start();
|
||||||
|
for (int i = 0; i < 10; i++)
|
||||||
|
{
|
||||||
|
for (int cs = 0; cs < numberOfCallsigns; cs++)
|
||||||
|
{
|
||||||
|
CCallsign callsign("CS" + QString::number(cs));
|
||||||
|
CAircraftSituationList r = situations.findByCallsign(callsign);
|
||||||
|
Q_ASSERT(r.size() == numberOfTimes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
out << "Reads by callsigns: " << timer.elapsed() << "ms" << endl;
|
||||||
|
|
||||||
|
timer.start();
|
||||||
|
for (int i = 0; i < 10; i++)
|
||||||
|
{
|
||||||
|
for (int t = 0; t < numberOfTimes; t++)
|
||||||
|
{
|
||||||
|
CAircraftSituationList r = situations.findBefore(baseTimeEpoch + 1 + (10 * t));
|
||||||
|
Q_ASSERT(r.size() == numberOfCallsigns * (t + 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
out << "Reads by times: " << timer.elapsed() << "ms" << endl;
|
||||||
|
|
||||||
|
timer.start();
|
||||||
|
for (int t = 0; t < numberOfTimes; t++)
|
||||||
|
{
|
||||||
|
for (int cs = 0; cs < numberOfCallsigns; cs++)
|
||||||
|
{
|
||||||
|
CCallsign callsign("CS" + QString::number(cs));
|
||||||
|
CAircraftSituationList r = situations.findByCallsign(callsign).findBefore(baseTimeEpoch + 1 + (10 * t));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
out << "Reads by callsign / times: " << timer.elapsed() << "ms" << endl;
|
||||||
|
|
||||||
|
timer.start();
|
||||||
|
for (int t = 0; t < numberOfTimes; t++)
|
||||||
|
{
|
||||||
|
for (int cs = 0; cs < numberOfCallsigns; cs++)
|
||||||
|
{
|
||||||
|
CCallsign callsign("CS" + QString::number(cs));
|
||||||
|
CAircraftSituationList r = situations.findBefore(baseTimeEpoch + 1 + (10 * t)).findByCallsign(callsign);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
out << "Reads by times / callsign: " << timer.elapsed() << "ms" << endl;
|
||||||
|
|
||||||
|
situations.changeImpl<QVector<CAircraftSituation> >();
|
||||||
|
out << "Changed to QVector" << endl;
|
||||||
|
timer.start();
|
||||||
|
for (int i = 0; i < 10; i++)
|
||||||
|
{
|
||||||
|
for (int cs = 0; cs < numberOfCallsigns; cs++)
|
||||||
|
{
|
||||||
|
CCallsign callsign("CS" + QString::number(cs));
|
||||||
|
CAircraftSituationList r = situations.findByCallsign(callsign);
|
||||||
|
Q_ASSERT(r.size() == numberOfTimes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
out << "Reads by callsigns: " << timer.elapsed() << "ms" << endl;
|
||||||
|
|
||||||
|
timer.start();
|
||||||
|
for (int i = 0; i < 10; i++)
|
||||||
|
{
|
||||||
|
for (int t = 0; t < numberOfTimes; t++)
|
||||||
|
{
|
||||||
|
CAircraftSituationList r = situations.findBefore(baseTimeEpoch + 1 + (10 * t));
|
||||||
|
Q_ASSERT(r.size() == numberOfCallsigns * (t + 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
out << "Reads by times: " << timer.elapsed() << "ms" << endl << endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -20,8 +20,12 @@ namespace BlackMiscTest
|
|||||||
class CSamplesPerformance
|
class CSamplesPerformance
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//! Run the samples
|
//! Copy, create, RegEx
|
||||||
static int samples(QTextStream &out);
|
static int samplesMisc(QTextStream &out);
|
||||||
|
|
||||||
|
//! Impact of implementation type
|
||||||
|
static int samplesImplementationType(QTextStream &out, int numberOfCallsigns, int numberOfTimes);
|
||||||
|
|
||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user