Don't create a QProcess object every second.

Creating a QProcess every second is very VERY expensive, making the QtCreator UI
experience pretty bad, the UI was not responsive when debugging or even when
running an Android application from QtCreator.

Thanks to Intel's VTUNE I could spot and fix the problem in minutes.

Change-Id: I6d3dc71db93e91d9846101a1877bab017df41aba
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
BogDan Vatra
2016-03-07 18:49:09 +02:00
parent 6884b377db
commit bf3ba0f577
2 changed files with 10 additions and 8 deletions

View File

@@ -249,15 +249,13 @@ static int extractPid(const QString &exeName, const QByteArray &psOutput)
QByteArray AndroidRunner::runPs()
{
QProcess psProc;
QStringList args = m_selector;
args << _("shell") << _("ps");
QByteArray psLine("ps");
if (m_isBusyBox)
args << _("-w");
psProc.start(m_adb, args);
psProc.waitForFinished();
return psProc.readAll();
psLine += " -w";
psLine += '\n';
m_psProc.write(psLine);
m_psProc.waitForBytesWritten(psLine.size());
return m_psProc.readAllStandardOutput();
}
void AndroidRunner::checkPID()
@@ -322,6 +320,7 @@ void AndroidRunner::forceStop()
void AndroidRunner::start()
{
m_adbLogcatProcess.start(m_adb, selector() << _("logcat"));
m_psProc.start(m_adb, selector() << _("shell"));
Utils::runAsync(&AndroidRunner::asyncStart, this);
}
@@ -551,6 +550,8 @@ void AndroidRunner::stop()
//QObject::disconnect(&m_adbLogcatProcess, 0, this, 0);
m_adbLogcatProcess.kill();
m_adbLogcatProcess.waitForFinished();
m_psProc.kill();
m_psProc.waitForFinished();
foreach (const QStringList &entry, m_androidRunnable.afterFinishADBCommands) {
QProcess adb;
adb.start(m_adb, selector() << entry);