diff options
| author | Aurindam Jana <aurindam.jana@nokia.com> | 2011-11-15 15:04:25 +0100 |
|---|---|---|
| committer | Aurindam Jana <aurindam.jana@nokia.com> | 2011-12-14 11:39:19 +0100 |
| commit | 28844621e4d218284e916f89eeaad299e6f10ba5 (patch) | |
| tree | c4c738c93843233dc4f201a823ad0e2fd672257d /src/tools/qmlprofilertool | |
| parent | 7e01f47b5fad23addf330b42e242bce3bf647977 (diff) | |
| download | qt-creator-28844621e4d218284e916f89eeaad299e6f10ba5.tar.gz | |
QmlProfiler: Show profiling data initiated by console APIs
The profile clients now also listens to profiling data sent by
console APIs console.profile and console.profileEnd
Change-Id: I7f7100448263889076e94a1e251b8977ce047843
Reviewed-by: Christiaan Janssen <christiaan.janssen@nokia.com>
Diffstat (limited to 'src/tools/qmlprofilertool')
| -rw-r--r-- | src/tools/qmlprofilertool/qmlprofilerapplication.cpp | 74 | ||||
| -rw-r--r-- | src/tools/qmlprofilertool/qmlprofilerapplication.h | 6 |
2 files changed, 45 insertions, 35 deletions
diff --git a/src/tools/qmlprofilertool/qmlprofilerapplication.cpp b/src/tools/qmlprofilertool/qmlprofilerapplication.cpp index 33ee02faa7..f0207f7923 100644 --- a/src/tools/qmlprofilertool/qmlprofilerapplication.cpp +++ b/src/tools/qmlprofilertool/qmlprofilerapplication.cpp @@ -58,7 +58,7 @@ static const char usageTextC[] = " -help Show this information and exit.\n" " -fromStart\n" " Record as soon as the engine is started, default is false.\n" -" -p=<number>, -port=<number>\n" +" -p <number>, -port <number>\n" " TCP/IP port to use, default is 3768.\n" " -v, -verbose\n" " Print debugging output.\n" @@ -83,7 +83,7 @@ QmlProfilerApplication::QmlProfilerApplication(int &argc, char **argv) : m_port(3768), m_verbose(false), m_quitAfterSave(false), - m_traceClient(&m_connection), + m_qmlProfilerClient(&m_connection), m_v8profilerClient(&m_connection), m_connectionAttempts(0) { @@ -94,17 +94,17 @@ QmlProfilerApplication::QmlProfilerApplication(int &argc, char **argv) : connect(&m_connection, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(connectionStateChanged(QAbstractSocket::SocketState))); connect(&m_connection, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(connectionError(QAbstractSocket::SocketError))); - connect(&m_traceClient, SIGNAL(enabled()), this, SLOT(traceClientEnabled())); - connect(&m_traceClient, SIGNAL(recordingChanged(bool)), this, SLOT(recordingChanged())); - connect(&m_traceClient, SIGNAL(range(int,qint64,qint64,QStringList,QString,int)), &m_eventList, SLOT(addRangedEvent(int,qint64,qint64,QStringList,QString,int))); - connect(&m_traceClient, SIGNAL(complete()), this, SLOT(qmlComplete())); + connect(&m_qmlProfilerClient, SIGNAL(enabled()), this, SLOT(traceClientEnabled())); + connect(&m_qmlProfilerClient, SIGNAL(recordingChanged(bool)), this, SLOT(recordingChanged())); + connect(&m_qmlProfilerClient, SIGNAL(range(int,qint64,qint64,QStringList,QString,int)), &m_eventList, SLOT(addRangedEvent(int,qint64,qint64,QStringList,QString,int))); + connect(&m_qmlProfilerClient, SIGNAL(complete()), this, SLOT(qmlComplete())); + connect(&m_v8profilerClient, SIGNAL(enabled()), this, SLOT(profilerClientEnabled())); connect(&m_v8profilerClient, SIGNAL(v8range(int,QString,QString,int,double,double)), &m_eventList, SLOT(addV8Event(int,QString,QString,int,double,double))); - connect(&m_v8profilerClient, SIGNAL(v8complete()), this, SLOT(v8complete())); + connect(&m_v8profilerClient, SIGNAL(complete()), this, SLOT(v8Complete())); connect(&m_eventList, SIGNAL(error(QString)), this, SLOT(logError(QString))); connect(&m_eventList, SIGNAL(dataReady()), this, SLOT(traceFinished())); - connect(this, SIGNAL(done()), &m_eventList, SLOT(complete())); } QmlProfilerApplication::~QmlProfilerApplication() @@ -143,7 +143,7 @@ bool QmlProfilerApplication::parseArguments() return false; } } else if (arg == QLatin1String("-fromStart")) { - m_traceClient.setRecording(true); + m_qmlProfilerClient.setRecording(true); m_v8profilerClient.setRecording(true); } else if (arg == QLatin1String("-help") || arg == QLatin1String("-h") || arg == QLatin1String("/h") || arg == QLatin1String("/?")) { return false; @@ -204,7 +204,8 @@ QString QmlProfilerApplication::traceFileName() const } while (QFileInfo(baseName + TraceFileExtension).exists()); fileName = baseName + TraceFileExtension; } - return fileName; + + return QFileInfo(fileName).absoluteFilePath(); } void QmlProfilerApplication::userCommand(const QString &command) @@ -216,23 +217,22 @@ void QmlProfilerApplication::userCommand(const QString &command) printCommands(); } else if (cmd == Constants::CMD_RECORD || cmd == Constants::CMD_RECORD2) { - m_traceClient.setRecording(!m_traceClient.isRecording()); + m_qmlProfilerClient.setRecording(!m_qmlProfilerClient.isRecording()); + m_v8profilerClient.setRecording(!m_v8profilerClient.isRecording()); m_qmlDataReady = false; m_v8DataReady = false; } else if (cmd == Constants::CMD_QUIT || cmd == Constants::CMD_QUIT2) { - if (m_traceClient.isRecording()) { + print(QLatin1String("Quit")); + if (m_qmlProfilerClient.isRecording()) { m_quitAfterSave = true; m_qmlDataReady = false; m_v8DataReady = false; - m_traceClient.setRecording(false); + m_qmlProfilerClient.setRecording(false); m_v8profilerClient.setRecording(false); } else { quit(); } - } else { - logError(QString("Unknown command '%1'").arg(cmd)); - printCommands(); } } @@ -278,11 +278,13 @@ void QmlProfilerApplication::tryToConnect() void QmlProfilerApplication::connected() { m_connectTimer.stop(); - if (m_traceClient.isRecording()) { - logStatus("Connected. Recording is on."); - } else { - logStatus("Connected. Recording is off."); - } + print(QString(QLatin1String("Connected to host:port %1:%2. Wait for profile data or type a command (type 'help'' to show list of commands).")).arg(m_hostName).arg((m_port))); + QString recordingStatus(QLatin1String("Recording Status: %1")); + if (!m_qmlProfilerClient.isRecording() && !m_v8profilerClient.isRecording()) + recordingStatus.arg(QLatin1String("Off")); + else + recordingStatus.arg(QLatin1String("On")); + print(recordingStatus); } void QmlProfilerApplication::connectionStateChanged(QAbstractSocket::SocketState state) @@ -312,7 +314,7 @@ void QmlProfilerApplication::processFinished() if (m_process->exitStatus() == QProcess::NormalExit) { logStatus(QString("Process exited (%1).").arg(m_process->exitCode())); - if (m_traceClient.isRecording()) { + if (m_qmlProfilerClient.isRecording()) { logError("Process exited while recording, last trace is lost!"); exit(2); } else { @@ -326,25 +328,35 @@ void QmlProfilerApplication::processFinished() void QmlProfilerApplication::traceClientEnabled() { + if (m_verbose) + qDebug() << "Trace client is attached."; logStatus("Trace client is attached."); } +void QmlProfilerApplication::profilerClientEnabled() +{ + if (m_verbose) + qDebug() << "Profiler client is attached."; + logStatus("Profiler client is attached."); +} + void QmlProfilerApplication::traceFinished() { const QString fileName = traceFileName(); - print(QString("Saving trace to %1.").arg(fileName)); - m_eventList.save(fileName); + + if (m_eventList.save(fileName)) + print(QString("Saving trace to %1.").arg(fileName)); + if (m_quitAfterSave) quit(); } void QmlProfilerApplication::recordingChanged() { - QTextStream err(stderr); - if (m_traceClient.isRecording()) { - err << "Recording is on." << endl; + if (m_qmlProfilerClient.isRecording()) { + print(QLatin1String("Recording is on.")); } else { - err << "Recording is off." << endl; + print(QLatin1String("Recording is off.")); } } @@ -372,12 +384,12 @@ void QmlProfilerApplication::qmlComplete() { m_qmlDataReady = true; if (m_v8profilerClient.status() != QDeclarativeDebugClient::Enabled || m_v8DataReady) - emit done(); + m_eventList.complete(); } void QmlProfilerApplication::v8Complete() { m_v8DataReady = true; - if (m_traceClient.status() != QDeclarativeDebugClient::Enabled || m_qmlDataReady) - emit done(); + if (m_qmlProfilerClient.status() != QDeclarativeDebugClient::Enabled || m_qmlDataReady) + m_eventList.complete(); } diff --git a/src/tools/qmlprofilertool/qmlprofilerapplication.h b/src/tools/qmlprofilertool/qmlprofilerapplication.h index bf0e48ad8a..b09619474e 100644 --- a/src/tools/qmlprofilertool/qmlprofilerapplication.h +++ b/src/tools/qmlprofilertool/qmlprofilerapplication.h @@ -55,9 +55,6 @@ public: void printUsage(); int exec(); -signals: - void done(); - public slots: void userCommand(const QString &command); @@ -71,6 +68,7 @@ private slots: void processFinished(); void traceClientEnabled(); + void profilerClientEnabled(); void traceFinished(); void recordingChanged(); @@ -102,7 +100,7 @@ private: bool m_quitAfterSave; QmlJsDebugClient::QDeclarativeDebugConnection m_connection; - QmlJsDebugClient::QmlProfilerTraceClient m_traceClient; + QmlJsDebugClient::QmlProfilerTraceClient m_qmlProfilerClient; QmlJsDebugClient::QV8ProfilerClient m_v8profilerClient; QmlJsDebugClient::QmlProfilerEventList m_eventList; QTimer m_connectTimer; |
