From 8fc9828a369b227d94428f4015b6f5006d312517 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 13 Dec 2018 12:06:09 +0100 Subject: 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 Reviewed-by: Simon Hausmann --- tools/qmlprofiler/qmlprofilerapplication.cpp | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) (limited to 'tools/qmlprofiler') diff --git a/tools/qmlprofiler/qmlprofilerapplication.cpp b/tools/qmlprofiler/qmlprofilerapplication.cpp index 04ad4b31e2..a1e4d9a153 100644 --- a/tools/qmlprofiler/qmlprofilerapplication.cpp +++ b/tools/qmlprofiler/qmlprofilerapplication.cpp @@ -29,7 +29,6 @@ #include "qmlprofilerapplication.h" #include "constants.h" #include -#include #include #include #include @@ -38,6 +37,8 @@ #include #include +#include + 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; } -- cgit v1.2.3