forked from qt-creator/qt-creator
QmlProfiler: ongoing work
This commit is contained in:
@@ -96,10 +96,10 @@ public:
|
|||||||
public slots:
|
public slots:
|
||||||
void showStatusMessage(const QString &message, int timeoutMS = 10000);
|
void showStatusMessage(const QString &message, int timeoutMS = 10000);
|
||||||
void showPermanentStatusMessage(const QString &message);
|
void showPermanentStatusMessage(const QString &message);
|
||||||
|
|
||||||
private slots:
|
|
||||||
void startTool();
|
void startTool();
|
||||||
void stopTool();
|
void stopTool();
|
||||||
|
|
||||||
|
private slots:
|
||||||
void handleToolFinished();
|
void handleToolFinished();
|
||||||
void toolSelected(int);
|
void toolSelected(int);
|
||||||
void toolSelected(QAction *);
|
void toolSelected(QAction *);
|
||||||
|
@@ -1,26 +0,0 @@
|
|||||||
import QtQuick 1.1
|
|
||||||
import Monitor 1.0
|
|
||||||
import "MainView.js" as Plotter
|
|
||||||
|
|
||||||
Text {
|
|
||||||
id: elapsed
|
|
||||||
color: "white"
|
|
||||||
|
|
||||||
Timer {
|
|
||||||
property date startDate
|
|
||||||
property bool reset: true
|
|
||||||
running: connection.recording
|
|
||||||
repeat: true
|
|
||||||
onRunningChanged: if (running) reset = true
|
|
||||||
interval: 100
|
|
||||||
triggeredOnStart: true
|
|
||||||
onTriggered: {
|
|
||||||
if (reset) {
|
|
||||||
startDate = new Date()
|
|
||||||
reset = false
|
|
||||||
}
|
|
||||||
var time = (new Date() - startDate)/1000
|
|
||||||
elapsed.text = time.toFixed(1) + "s"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -60,6 +60,29 @@ Rectangle {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Elapsed
|
||||||
|
property real elapsedTime;
|
||||||
|
signal updateTimer;
|
||||||
|
Timer {
|
||||||
|
property date startDate
|
||||||
|
property bool reset: true
|
||||||
|
running: connection.recording
|
||||||
|
repeat: true
|
||||||
|
onRunningChanged: if (running) reset = true
|
||||||
|
interval: 100
|
||||||
|
triggeredOnStart: true
|
||||||
|
onTriggered: {
|
||||||
|
if (reset) {
|
||||||
|
startDate = new Date()
|
||||||
|
reset = false
|
||||||
|
}
|
||||||
|
var time = (new Date() - startDate)/1000
|
||||||
|
//elapsed.text = time.toFixed(1) + "s"
|
||||||
|
root.elapsedTime = time.toFixed(1);
|
||||||
|
root.updateTimer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//timeline background
|
//timeline background
|
||||||
Item {
|
Item {
|
||||||
anchors.fill: flick
|
anchors.fill: flick
|
||||||
@@ -246,17 +269,4 @@ Rectangle {
|
|||||||
anchors.top: canvas.top
|
anchors.top: canvas.top
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
width: 50
|
|
||||||
height: 30
|
|
||||||
anchors.right: root.right
|
|
||||||
anchors.top: root.top
|
|
||||||
radius: 4
|
|
||||||
color: "#606085"
|
|
||||||
Elapsed {
|
|
||||||
anchors.centerIn: parent
|
|
||||||
horizontalAlignment: Text.AlignHCenter
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
<RCC>
|
<RCC>
|
||||||
<qresource prefix="/qml">
|
<qresource prefix="/qml">
|
||||||
<file>Detail.qml</file>
|
<file>Detail.qml</file>
|
||||||
<file>Elapsed.qml</file>
|
|
||||||
<file>Label.qml</file>
|
<file>Label.qml</file>
|
||||||
<file>lock.png</file>
|
<file>lock.png</file>
|
||||||
<file>MainView.js</file>
|
<file>MainView.js</file>
|
||||||
|
@@ -3,6 +3,9 @@
|
|||||||
#include "qmlprofilerplugin.h"
|
#include "qmlprofilerplugin.h"
|
||||||
#include "qmlprofilertool.h"
|
#include "qmlprofilertool.h"
|
||||||
|
|
||||||
|
#include <analyzerbase/analyzermanager.h>
|
||||||
|
#include <analyzerbase/analyzerconstants.h>
|
||||||
|
|
||||||
#include <projectexplorer/applicationrunconfiguration.h>
|
#include <projectexplorer/applicationrunconfiguration.h>
|
||||||
|
|
||||||
#include <private/qdeclarativedebugclient_p.h>
|
#include <private/qdeclarativedebugclient_p.h>
|
||||||
@@ -83,16 +86,27 @@ void QmlProfilerEngine::stop()
|
|||||||
emit stopRecording();
|
emit stopRecording();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QmlProfilerEngine::spontaneousStop()
|
||||||
|
{
|
||||||
|
AnalyzerManager::instance()->stopTool();
|
||||||
|
}
|
||||||
|
|
||||||
void QmlProfilerEngine::viewUpdated()
|
void QmlProfilerEngine::viewUpdated()
|
||||||
{
|
{
|
||||||
|
if (d->m_process) {
|
||||||
|
disconnect(d->m_process,SIGNAL(finished(int)),this,SLOT(spontaneousStop()));
|
||||||
|
if (d->m_process->state() == QProcess::Running) {
|
||||||
d->m_process->terminate();
|
d->m_process->terminate();
|
||||||
if (!d->m_process->waitForFinished(1000)) {
|
if (!d->m_process->waitForFinished(1000)) {
|
||||||
d->m_process->kill();
|
d->m_process->kill();
|
||||||
d->m_process->waitForFinished();
|
d->m_process->waitForFinished();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
delete d->m_process;
|
||||||
|
d->m_process = 0;
|
||||||
|
}
|
||||||
|
|
||||||
emit processTerminated();
|
emit processTerminated();
|
||||||
delete d->m_process;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QmlProfilerEngine::QmlProfilerEnginePrivate::launchperfmonitor()
|
bool QmlProfilerEngine::QmlProfilerEnginePrivate::launchperfmonitor()
|
||||||
@@ -113,16 +127,18 @@ bool QmlProfilerEngine::QmlProfilerEnginePrivate::launchperfmonitor()
|
|||||||
|
|
||||||
m_process->setProcessChannelMode(QProcess::ForwardedChannels);
|
m_process->setProcessChannelMode(QProcess::ForwardedChannels);
|
||||||
m_process->setWorkingDirectory(m_workingDirectory);
|
m_process->setWorkingDirectory(m_workingDirectory);
|
||||||
|
connect(m_process,SIGNAL(finished(int)),q,SLOT(spontaneousStop()));
|
||||||
m_process->start(m_executable, arguments);
|
m_process->start(m_executable, arguments);
|
||||||
|
|
||||||
|
// give the process time to start
|
||||||
|
sleep(1);
|
||||||
|
|
||||||
if (!m_process->waitForStarted()) {
|
if (!m_process->waitForStarted()) {
|
||||||
if (QmlProfilerPlugin::debugOutput)
|
if (QmlProfilerPlugin::debugOutput)
|
||||||
qWarning("QmlProfiler: %s failed to start", qPrintable(m_executable));
|
qWarning("QmlProfiler: %s failed to start", qPrintable(m_executable));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
sleep(1);
|
|
||||||
|
|
||||||
if (QmlProfilerPlugin::debugOutput)
|
if (QmlProfilerPlugin::debugOutput)
|
||||||
qWarning("QmlProfiler: Connecting to %s:%d", qPrintable(QmlProfilerTool::host), QmlProfilerTool::port);
|
qWarning("QmlProfiler: Connecting to %s:%d", qPrintable(QmlProfilerTool::host), QmlProfilerTool::port);
|
||||||
|
|
||||||
|
@@ -14,15 +14,16 @@ public:
|
|||||||
explicit QmlProfilerEngine(ProjectExplorer::RunConfiguration *runConfiguration);
|
explicit QmlProfilerEngine(ProjectExplorer::RunConfiguration *runConfiguration);
|
||||||
~QmlProfilerEngine();
|
~QmlProfilerEngine();
|
||||||
|
|
||||||
void start();
|
|
||||||
void stop();
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void processRunning();
|
void processRunning();
|
||||||
void processTerminated();
|
void processTerminated();
|
||||||
void stopRecording();
|
void stopRecording();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
void start();
|
||||||
|
void stop();
|
||||||
|
void spontaneousStop();
|
||||||
|
|
||||||
void viewUpdated();
|
void viewUpdated();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@@ -25,12 +25,15 @@
|
|||||||
|
|
||||||
#include <QtCore/QFile>
|
#include <QtCore/QFile>
|
||||||
|
|
||||||
|
#include <QtGui/QHBoxLayout>
|
||||||
|
#include <QtGui/QLabel>
|
||||||
|
|
||||||
|
|
||||||
using namespace Analyzer;
|
using namespace Analyzer;
|
||||||
using namespace Analyzer::Internal;
|
using namespace Analyzer::Internal;
|
||||||
|
|
||||||
QString QmlProfilerTool::host = QLatin1String("localhost");
|
QString QmlProfilerTool::host = QLatin1String("localhost");
|
||||||
quint16 QmlProfilerTool::port = 33455;
|
quint16 QmlProfilerTool::port = 33456;
|
||||||
|
|
||||||
|
|
||||||
// Adapter for output pane.
|
// Adapter for output pane.
|
||||||
@@ -112,6 +115,7 @@ IAnalyzerEngine *QmlProfilerTool::createEngine(ProjectExplorer::RunConfiguration
|
|||||||
connect(engine, SIGNAL(stopRecording()), this, SLOT(stopRecording()));
|
connect(engine, SIGNAL(stopRecording()), this, SLOT(stopRecording()));
|
||||||
connect(d->m_traceWindow, SIGNAL(viewUpdated()), engine, SLOT(viewUpdated()));
|
connect(d->m_traceWindow, SIGNAL(viewUpdated()), engine, SLOT(viewUpdated()));
|
||||||
connect(d->m_traceWindow, SIGNAL(gotoSourceLocation(QString,int)), this, SLOT(gotoSourceLocation(QString,int)));
|
connect(d->m_traceWindow, SIGNAL(gotoSourceLocation(QString,int)), this, SLOT(gotoSourceLocation(QString,int)));
|
||||||
|
connect(d->m_traceWindow, SIGNAL(timeChanged(qreal)), this, SLOT(updateTimer(qreal)));
|
||||||
|
|
||||||
return engine;
|
return engine;
|
||||||
|
|
||||||
@@ -142,7 +146,23 @@ IAnalyzerOutputPaneAdapter *QmlProfilerTool::outputPaneAdapter()
|
|||||||
QWidget *QmlProfilerTool::createToolBarWidget()
|
QWidget *QmlProfilerTool::createToolBarWidget()
|
||||||
{
|
{
|
||||||
// custom toolbar (TODO)
|
// custom toolbar (TODO)
|
||||||
return 0;
|
QWidget *toolbarWidget = new QWidget;
|
||||||
|
toolbarWidget->setObjectName(QLatin1String("QmlProfilerToolBarWidget"));
|
||||||
|
|
||||||
|
QHBoxLayout *layout = new QHBoxLayout;
|
||||||
|
layout->setMargin(0);
|
||||||
|
layout->setSpacing(0);
|
||||||
|
|
||||||
|
QLabel *timeLabel = new QLabel(tr("elapsed: 0 s"));
|
||||||
|
QPalette palette = timeLabel->palette();
|
||||||
|
palette.setColor(QPalette::WindowText, Qt::white);
|
||||||
|
timeLabel->setPalette(palette);
|
||||||
|
|
||||||
|
connect(this,SIGNAL(setTimeLabel(QString)),timeLabel,SLOT(setText(QString)));
|
||||||
|
layout->addWidget(timeLabel);
|
||||||
|
toolbarWidget->setLayout(layout);
|
||||||
|
|
||||||
|
return toolbarWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *QmlProfilerTool::createTimeLineWidget()
|
QWidget *QmlProfilerTool::createTimeLineWidget()
|
||||||
@@ -203,3 +223,10 @@ void QmlProfilerTool::gotoSourceLocation(const QString &fileName, int lineNumber
|
|||||||
textEditor->widget()->setFocus();
|
textEditor->widget()->setFocus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QmlProfilerTool::updateTimer(qreal elapsedSeconds)
|
||||||
|
{
|
||||||
|
QString timeString = QString::number(elapsedSeconds,'f',1);
|
||||||
|
timeString = QString(" ").left(6-timeString.length()) + timeString;
|
||||||
|
emit setTimeLabel(tr("elapsed: ")+timeString+QLatin1String(" s"));
|
||||||
|
}
|
||||||
|
@@ -33,6 +33,10 @@ public slots:
|
|||||||
void stopRecording();
|
void stopRecording();
|
||||||
|
|
||||||
void gotoSourceLocation(const QString &fileName, int lineNumber);
|
void gotoSourceLocation(const QString &fileName, int lineNumber);
|
||||||
|
void updateTimer(qreal elapsedSeconds);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void setTimeLabel(const QString &);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Todo: configurable parameters
|
// Todo: configurable parameters
|
||||||
|
@@ -288,6 +288,7 @@ void TraceWindow::reset(QDeclarativeDebugConnection *conn)
|
|||||||
m_view->setSource(QUrl("qrc:/qml/MainView.qml"));
|
m_view->setSource(QUrl("qrc:/qml/MainView.qml"));
|
||||||
|
|
||||||
connect(m_view->rootObject(), SIGNAL(updateCursorPosition()), this, SLOT(updateCursorPosition()));
|
connect(m_view->rootObject(), SIGNAL(updateCursorPosition()), this, SLOT(updateCursorPosition()));
|
||||||
|
connect(m_view->rootObject(), SIGNAL(updateTimer()), this, SLOT(updateTimer()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TraceWindow::updateCursorPosition()
|
void TraceWindow::updateCursorPosition()
|
||||||
@@ -296,6 +297,11 @@ void TraceWindow::updateCursorPosition()
|
|||||||
m_view->rootObject()->property("lineNumber").toInt());
|
m_view->rootObject()->property("lineNumber").toInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TraceWindow::updateTimer()
|
||||||
|
{
|
||||||
|
emit timeChanged(m_view->rootObject()->property("elapsedTime").toDouble());
|
||||||
|
}
|
||||||
|
|
||||||
void TraceWindow::setRecordAtStart(bool record)
|
void TraceWindow::setRecordAtStart(bool record)
|
||||||
{
|
{
|
||||||
m_recordAtStart = record;
|
m_recordAtStart = record;
|
||||||
|
@@ -60,10 +60,12 @@ public:
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void updateCursorPosition();
|
void updateCursorPosition();
|
||||||
|
void updateTimer();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void viewUpdated();
|
void viewUpdated();
|
||||||
void gotoSourceLocation(const QString &fileName, int lineNumber);
|
void gotoSourceLocation(const QString &fileName, int lineNumber);
|
||||||
|
void timeChanged(qreal newTime);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TracePlugin *m_plugin;
|
TracePlugin *m_plugin;
|
||||||
|
Reference in New Issue
Block a user