qmlprofiler: Use std::cerr directly rather than through QTextStream

The application output already is in the right text encoding. There is
no point in re-encoding it. The re-encoding is actually expensive enough
to delay the target application in some cases, and that distorts the
profiling results.

Change-Id: I3a6c47801cba072f6cfff8d0d2c3d10725750d00
Reviewed-by: Martin Smith <martin.smith@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
This commit is contained in:
Ulf Hermann 2018-12-13 12:06:09 +01:00
parent ab26e8add8
commit 8fc9828a36
1 changed files with 10 additions and 16 deletions

View File

@ -29,7 +29,6 @@
#include "qmlprofilerapplication.h"
#include "constants.h"
#include <QtCore/QStringList>
#include <QtCore/QTextStream>
#include <QtCore/QProcess>
#include <QtCore/QTimer>
#include <QtCore/QDateTime>
@ -38,6 +37,8 @@
#include <QtCore/QCommandLineParser>
#include <QtCore/QTemporaryFile>
#include <iostream>
static const char commandTextC[] =
"The following commands are available:\n"
"'r', 'record'\n"
@ -120,10 +121,8 @@ QmlProfilerApplication::~QmlProfilerApplication()
logStatus("Killing process ...");
m_process->kill();
}
if (isInteractive()) {
QTextStream err(stderr);
err << endl;
}
if (isInteractive())
std::cerr << std::endl;
delete m_process;
}
@ -539,10 +538,8 @@ void QmlProfilerApplication::disconnected()
void QmlProfilerApplication::processHasOutput()
{
Q_ASSERT(m_process);
while (m_process->bytesAvailable()) {
QTextStream out(stderr);
out << m_process->readAll();
}
while (m_process->bytesAvailable())
std::cerr << m_process->readAll().constData();
}
void QmlProfilerApplication::processFinished()
@ -594,10 +591,9 @@ void QmlProfilerApplication::traceFinished()
void QmlProfilerApplication::prompt(const QString &line, bool ready)
{
if (m_interactive) {
QTextStream err(stderr);
if (!line.isEmpty())
err << line << endl;
err << QLatin1String("> ");
std::cerr << qPrintable(line) << std::endl;
std::cerr << "> ";
if (ready)
emit readyForCommand();
}
@ -605,14 +601,12 @@ void QmlProfilerApplication::prompt(const QString &line, bool ready)
void QmlProfilerApplication::logError(const QString &error)
{
QTextStream err(stderr);
err << "Error: " << error << endl;
std::cerr << "Error: " << qPrintable(error) << std::endl;
}
void QmlProfilerApplication::logStatus(const QString &status)
{
if (!m_verbose)
return;
QTextStream err(stderr);
err << status << endl;
std::cerr << qPrintable(status) << std::endl;
}