Skip to content

Commit

Permalink
[libcommhistory] Remove broken idle checks on performance tests. Fixe…
Browse files Browse the repository at this point in the history
…s JB#53609

The checks themselves increased load so much that the testing just
got stuck.

Let's just remove, the one who runs the tests should make sure
there are no things that could affect the results too much.
  • Loading branch information
pvuorela committed Mar 19, 2021
1 parent 91a353c commit 6a18c1c
Show file tree
Hide file tree
Showing 10 changed files with 0 additions and 87 deletions.
63 changes: 0 additions & 63 deletions tests/common.cpp
Expand Up @@ -514,69 +514,6 @@ QString randomMessage(int words)
return msg;
}

/*
* Returns the average system load since last time this function was called (or
* since boot if this first time this function is called). The scale is [1, 0],
* where 1 is busy and 0 is idle system. In case of errors, -1 is returned.
*/
double getSystemLoad()
{
// Parsing assumes that first line of /proc/stat looks something like this:
// cpu 110807 325 23491 425840 37435 1367 32 0 0

QFile file("/proc/stat");
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
qWarning() << Q_FUNC_INFO << "Failed to open /proc/stat";
return -1;
}

QTextStream in(&file);
QString line = in.readLine();
file.close();

QStringList parts = line.split(" ", QString::SkipEmptyParts);
if (parts.size() < 10) {
qWarning() << Q_FUNC_INFO << "Invalid input from /proc/stat:" << line;
return -1;
}
if (parts.at(0) != QStringLiteral("cpu")) {
qWarning() << Q_FUNC_INFO << "Invalid input from /proc/stat:" << line;
return -1;
}

int newIdleTicks = parts.at(4).toInt();
int newAllTicks = 0;
for (int i = 1; i < parts.count(); i++) {
newAllTicks += parts.at(i).toInt();
}

quint64 idleTickDelta = newIdleTicks - idleTicks;
quint64 allTickDelta = newAllTicks - allTicks;
idleTicks = newIdleTicks;
allTicks = newAllTicks;

return 1.0 - ((double)idleTickDelta / allTickDelta);
}

/*
* Wait in semi-busy loop until system load drops below IDLE_TRESHOLD
*/
void waitForIdle(int pollInterval) {
double load = 1.0;
QDateTime startTime = QDateTime::currentDateTime();
getSystemLoad();
while (load > IDLE_TRESHOLD) {
qDebug() << Q_FUNC_INFO << "Waiting system to calm down. Wait time:"
<< startTime.secsTo(QDateTime::currentDateTime()) << "seconds. Load:"
<< load * 100 << "\%";
QTest::qWait(pollInterval);
load = getSystemLoad();
}
qDebug() << Q_FUNC_INFO << "Done. Wait time:"
<< startTime.secsTo(QDateTime::currentDateTime()) << "seconds. Load:"
<< load * 100 << "\%";
}

bool waitSignal(QSignalSpy &spy, int msec)
{
if (!spy.isEmpty()) {
Expand Down
8 changes: 0 additions & 8 deletions tests/common.h
Expand Up @@ -58,12 +58,6 @@ const QString TEST_DATABASE_DIR = QStandardPaths::writableLocation(QStandardPath
const QString ACCOUNT1 = "/org/freedesktop/Telepathy/Account/gabble/jabber/dut_40localhost0";
const QString ACCOUNT2 = "/org/freedesktop/Telepathy/Account/gabble/jabber/dut2_40localhost0";

/* The default load polling interval when waiting system to become idle */
const int IDLE_POLL_INTERVAL = 500;

/* System is considered idle when system load drops below this value */
const double IDLE_TRESHOLD = 0.07; // 7% (system often sits at 5-6%)

const int WAIT_SIGNAL_TIMEOUT = 5000;

/* Duration of phone calls added with addTestEvent */
Expand Down Expand Up @@ -98,8 +92,6 @@ void cleanupTestEvents();
bool compareEvents(Event &e1, Event &e2);
void deleteAll();
QString randomMessage(int words);
double getSystemLoad();
void waitForIdle(int pollInterval = IDLE_POLL_INTERVAL);
bool waitSignal(QSignalSpy &spy, int msec = WAIT_SIGNAL_TIMEOUT);
// wait and allow deferred deletes to be processed (http://bugreports.qt.nokia.com/browse/QTBUG-12575)
void waitWithDeletes(int msec = WAIT_SIGNAL_TIMEOUT);
Expand Down
2 changes: 0 additions & 2 deletions tests/perf_callmodel/callmodelperftest.cpp
Expand Up @@ -201,8 +201,6 @@ void CallModelPerfTest::getEvents()
fetchModel.setResolveContacts(resolve ? EventModel::ResolveImmediately : EventModel::DoNotResolve);
fetchModel.setFilter(CallModel::SortByContact);

waitForIdle();

QTime time;
time.start();

Expand Down
2 changes: 0 additions & 2 deletions tests/perf_conversationmodel/conversationmodelperftest.cpp
Expand Up @@ -228,8 +228,6 @@ void ConversationModelPerfTest::getEvents()
fetchModel.setChunkSize(limit);
}

waitForIdle();

QTime time;
time.start();
bool result = fetchModel.getEvents(groupIds);
Expand Down
2 changes: 0 additions & 2 deletions tests/perf_groupmodel/groupmodelperftest.cpp
Expand Up @@ -214,8 +214,6 @@ void GroupModelPerfTest::getGroups()

fetchModel.setManager(&manager);

waitForIdle();

QTime time;
time.start();
bool result = fetchModel.getGroups();
Expand Down
Expand Up @@ -203,8 +203,6 @@ void RecentContactsModelPerfTest::getEvents()
if (limit)
fetchModel.setLimit(limit);

waitForIdle();

QTime time;
time.start();

Expand Down
2 changes: 0 additions & 2 deletions tests/profile_callmodel/callmodelprofiletest.cpp
Expand Up @@ -161,8 +161,6 @@ void CallModelProfileTest::execute()
fetchModel.setResolveContacts(resolve ? EventModel::ResolveImmediately : EventModel::DoNotResolve);
fetchModel.setFilter(CallModel::SortByContact);

waitForIdle();

QTime time;
time.start();

Expand Down
Expand Up @@ -184,8 +184,6 @@ void ConversationModelProfileTest::execute()
fetchModel.setChunkSize(limit);
}

waitForIdle();

QTime time;
time.start();
bool result = fetchModel.getEvents();
Expand Down
2 changes: 0 additions & 2 deletions tests/profile_groupmodel/groupmodelprofiletest.cpp
Expand Up @@ -169,8 +169,6 @@ void GroupModelProfileTest::execute()

fetchModel.setManager(&manager);

waitForIdle();

QTime time;
time.start();

Expand Down
Expand Up @@ -173,8 +173,6 @@ void RecentContactsModelProfileTest::execute()
RecentContactsModel fetchModel;
fetchModel.setLimit(limit);

waitForIdle();

QTime time;
time.start();

Expand Down

0 comments on commit 6a18c1c

Please sign in to comment.