forked from qt-creator/qt-creator
QmlProfiler: timers for all profiler activities
Change-Id: I2ecbf4d1d90e353506e7c164560b69b81fcc6c66 Reviewed-by: Aurindam Jana <aurindam.jana@nokia.com> Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
This commit is contained in:
@@ -164,6 +164,8 @@ public:
|
|||||||
|
|
||||||
qint64 m_traceEndTime;
|
qint64 m_traceEndTime;
|
||||||
qint64 m_traceStartTime;
|
qint64 m_traceStartTime;
|
||||||
|
qint64 m_qmlMeasuredTime;
|
||||||
|
qint64 m_v8MeasuredTime;
|
||||||
|
|
||||||
// file to load
|
// file to load
|
||||||
QString m_filename;
|
QString m_filename;
|
||||||
@@ -180,6 +182,8 @@ QmlProfilerEventList::QmlProfilerEventList(QObject *parent) :
|
|||||||
|
|
||||||
d->m_traceEndTime = 0;
|
d->m_traceEndTime = 0;
|
||||||
d->m_traceStartTime = -1;
|
d->m_traceStartTime = -1;
|
||||||
|
d->m_qmlMeasuredTime = 0;
|
||||||
|
d->m_v8MeasuredTime = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlProfilerEventList::~QmlProfilerEventList()
|
QmlProfilerEventList::~QmlProfilerEventList()
|
||||||
@@ -206,6 +210,9 @@ void QmlProfilerEventList::clear()
|
|||||||
|
|
||||||
d->m_traceEndTime = 0;
|
d->m_traceEndTime = 0;
|
||||||
d->m_traceStartTime = -1;
|
d->m_traceStartTime = -1;
|
||||||
|
d->m_qmlMeasuredTime = 0;
|
||||||
|
d->m_v8MeasuredTime = 0;
|
||||||
|
|
||||||
emit countChanged();
|
emit countChanged();
|
||||||
emit dataClear();
|
emit dataClear();
|
||||||
}
|
}
|
||||||
@@ -339,6 +346,8 @@ void QmlProfilerEventList::addV8Event(int depth, const QString &function, const
|
|||||||
if (!parentEvent->childrenList.contains(newData))
|
if (!parentEvent->childrenList.contains(newData))
|
||||||
parentEvent->childrenList << newData;
|
parentEvent->childrenList << newData;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
d->m_v8MeasuredTime += totalTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -381,6 +390,7 @@ void QmlProfilerEventList::setTraceStartTime( qint64 time )
|
|||||||
|
|
||||||
void QmlProfilerEventList::complete()
|
void QmlProfilerEventList::complete()
|
||||||
{
|
{
|
||||||
|
emit postProcessing();
|
||||||
d->collectV8Statistics();
|
d->collectV8Statistics();
|
||||||
postProcess();
|
postProcess();
|
||||||
}
|
}
|
||||||
@@ -615,6 +625,10 @@ void QmlProfilerEventList::computeNestingLevels()
|
|||||||
|
|
||||||
d->m_startTimeSortedList[i].level = level;
|
d->m_startTimeSortedList[i].level = level;
|
||||||
d->m_startTimeSortedList[i].nestingLevel = nestingLevels[type];
|
d->m_startTimeSortedList[i].nestingLevel = nestingLevels[type];
|
||||||
|
|
||||||
|
if (level == MIN_LEVEL) {
|
||||||
|
d->m_qmlMeasuredTime += d->m_startTimeSortedList[i].length;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -792,6 +806,15 @@ qint64 QmlProfilerEventList::traceDuration() const
|
|||||||
return traceEndTime() - traceStartTime();
|
return traceEndTime() - traceStartTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qint64 QmlProfilerEventList::qmlMeasuredTime() const
|
||||||
|
{
|
||||||
|
return d->m_qmlMeasuredTime;
|
||||||
|
}
|
||||||
|
qint64 QmlProfilerEventList::v8MeasuredTime() const
|
||||||
|
{
|
||||||
|
return d->m_v8MeasuredTime;
|
||||||
|
}
|
||||||
|
|
||||||
int QmlProfilerEventList::count() const
|
int QmlProfilerEventList::count() const
|
||||||
{
|
{
|
||||||
return d->m_startTimeSortedList.count();
|
return d->m_startTimeSortedList.count();
|
||||||
@@ -1137,6 +1160,7 @@ void QmlProfilerEventList::load()
|
|||||||
|
|
||||||
descriptionBuffer.clear();
|
descriptionBuffer.clear();
|
||||||
|
|
||||||
|
emit postProcessing();
|
||||||
d->collectV8Statistics();
|
d->collectV8Statistics();
|
||||||
postProcess();
|
postProcess();
|
||||||
}
|
}
|
||||||
|
@@ -124,6 +124,8 @@ public:
|
|||||||
Q_INVOKABLE qint64 traceStartTime() const;
|
Q_INVOKABLE qint64 traceStartTime() const;
|
||||||
Q_INVOKABLE qint64 traceEndTime() const;
|
Q_INVOKABLE qint64 traceEndTime() const;
|
||||||
Q_INVOKABLE qint64 traceDuration() const;
|
Q_INVOKABLE qint64 traceDuration() const;
|
||||||
|
Q_INVOKABLE qint64 qmlMeasuredTime() const;
|
||||||
|
Q_INVOKABLE qint64 v8MeasuredTime() const;
|
||||||
|
|
||||||
void showErrorDialog(const QString &st ) const;
|
void showErrorDialog(const QString &st ) const;
|
||||||
void compileStatistics(qint64 startTime, qint64 endTime);
|
void compileStatistics(qint64 startTime, qint64 endTime);
|
||||||
@@ -133,6 +135,7 @@ signals:
|
|||||||
void error(const QString &error);
|
void error(const QString &error);
|
||||||
void dataClear();
|
void dataClear();
|
||||||
void processingData();
|
void processingData();
|
||||||
|
void postProcessing();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void clear();
|
void clear();
|
||||||
|
@@ -116,8 +116,8 @@ void QmlProfilerTraceClient::statusChanged(Status status)
|
|||||||
{
|
{
|
||||||
if (status == Enabled) {
|
if (status == Enabled) {
|
||||||
d->sendRecordingStatus();
|
d->sendRecordingStatus();
|
||||||
emit enabled();
|
|
||||||
}
|
}
|
||||||
|
emit enabledChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlProfilerTraceClient::messageReceived(const QByteArray &data)
|
void QmlProfilerTraceClient::messageReceived(const QByteArray &data)
|
||||||
|
@@ -53,7 +53,7 @@ struct QMLJSDEBUGCLIENT_EXPORT Location
|
|||||||
class QMLJSDEBUGCLIENT_EXPORT QmlProfilerTraceClient : public QmlJsDebugClient::QDeclarativeDebugClient
|
class QMLJSDEBUGCLIENT_EXPORT QmlProfilerTraceClient : public QmlJsDebugClient::QDeclarativeDebugClient
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(bool enabled READ isEnabled NOTIFY enabled)
|
Q_PROPERTY(bool enabled READ isEnabled NOTIFY enabledChanged)
|
||||||
Q_PROPERTY(bool recording READ isRecording WRITE setRecording NOTIFY recordingChanged)
|
Q_PROPERTY(bool recording READ isRecording WRITE setRecording NOTIFY recordingChanged)
|
||||||
|
|
||||||
// don't hide by signal
|
// don't hide by signal
|
||||||
@@ -103,7 +103,7 @@ signals:
|
|||||||
|
|
||||||
void recordingChanged(bool arg);
|
void recordingChanged(bool arg);
|
||||||
|
|
||||||
void enabled();
|
void enabledChanged();
|
||||||
void cleared();
|
void cleared();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@@ -85,6 +85,11 @@ void QV8ProfilerClient::clearData()
|
|||||||
emit cleared();
|
emit cleared();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool QV8ProfilerClient::isEnabled() const
|
||||||
|
{
|
||||||
|
return status() == Enabled;
|
||||||
|
}
|
||||||
|
|
||||||
bool QV8ProfilerClient::isRecording() const
|
bool QV8ProfilerClient::isRecording() const
|
||||||
{
|
{
|
||||||
return d->recording;
|
return d->recording;
|
||||||
@@ -108,8 +113,8 @@ void QV8ProfilerClient::statusChanged(Status status)
|
|||||||
{
|
{
|
||||||
if (status == Enabled) {
|
if (status == Enabled) {
|
||||||
d->sendRecordingStatus();
|
d->sendRecordingStatus();
|
||||||
emit enabled();
|
|
||||||
}
|
}
|
||||||
|
emit enabledChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QV8ProfilerClient::messageReceived(const QByteArray &data)
|
void QV8ProfilerClient::messageReceived(const QByteArray &data)
|
||||||
|
@@ -45,6 +45,7 @@ namespace QmlJsDebugClient {
|
|||||||
class QMLJSDEBUGCLIENT_EXPORT QV8ProfilerClient : public QDeclarativeDebugClient
|
class QMLJSDEBUGCLIENT_EXPORT QV8ProfilerClient : public QDeclarativeDebugClient
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(bool enabled READ isEnabled NOTIFY enabledChanged)
|
||||||
Q_PROPERTY(bool recording READ isRecording WRITE setRecording NOTIFY recordingChanged)
|
Q_PROPERTY(bool recording READ isRecording WRITE setRecording NOTIFY recordingChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -58,6 +59,7 @@ public:
|
|||||||
QV8ProfilerClient(QDeclarativeDebugConnection *client);
|
QV8ProfilerClient(QDeclarativeDebugConnection *client);
|
||||||
~QV8ProfilerClient();
|
~QV8ProfilerClient();
|
||||||
|
|
||||||
|
bool isEnabled() const;
|
||||||
bool isRecording() const;
|
bool isRecording() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
@@ -71,7 +73,7 @@ signals:
|
|||||||
|
|
||||||
void recordingChanged(bool arg);
|
void recordingChanged(bool arg);
|
||||||
|
|
||||||
void enabled();
|
void enabledChanged();
|
||||||
void cleared();
|
void cleared();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@@ -102,7 +102,7 @@ Rectangle {
|
|||||||
root.clearAll();
|
root.clearAll();
|
||||||
if (eventCount > 1) {
|
if (eventCount > 1) {
|
||||||
root.progress = Math.min(1.0,
|
root.progress = Math.min(1.0,
|
||||||
(qmlEventList.lastTimeMark() - qmlEventList.traceStartTime()) / root.elapsedTime * 1e-9 ) * 0.5;
|
(qmlEventList.lastTimeMark() - qmlEventList.traceStartTime()) / root.elapsedTime * 1e-9 );
|
||||||
} else {
|
} else {
|
||||||
root.progress = 0;
|
root.progress = 0;
|
||||||
}
|
}
|
||||||
@@ -112,6 +112,10 @@ Rectangle {
|
|||||||
root.dataAvailable = false;
|
root.dataAvailable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onPostProcessing: {
|
||||||
|
root.progress = 0.9; // jump to 90%
|
||||||
|
}
|
||||||
|
|
||||||
onDataReady: {
|
onDataReady: {
|
||||||
if (eventCount > 0) {
|
if (eventCount > 0) {
|
||||||
view.clearData();
|
view.clearData();
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
import QtQuick 1.0
|
import QtQuick 1.0
|
||||||
|
|
||||||
Rectangle {
|
Item {
|
||||||
id: statusDisplay
|
id: statusDisplay
|
||||||
|
|
||||||
property real percentage : root.progress
|
property real percentage : root.progress
|
||||||
@@ -10,10 +10,29 @@ Rectangle {
|
|||||||
|
|
||||||
visible: false;
|
visible: false;
|
||||||
|
|
||||||
color: "#CCD0CC"
|
// shadow
|
||||||
|
BorderImage {
|
||||||
|
property int px: 4
|
||||||
|
source: "dialog_shadow.png"
|
||||||
|
|
||||||
|
border {
|
||||||
|
left: px; top: px
|
||||||
|
right: px; bottom: px
|
||||||
|
}
|
||||||
|
width: parent.width + 2*px - 1
|
||||||
|
height: parent.height
|
||||||
|
x: -px + 1
|
||||||
|
y: px + 1
|
||||||
|
}
|
||||||
|
|
||||||
|
// background
|
||||||
|
Rectangle {
|
||||||
|
color: "#E0E0E0"
|
||||||
border.width: 1
|
border.width: 1
|
||||||
border.color: "#AAAEAA"
|
border.color: "#666666"
|
||||||
radius: 4
|
radius: 4
|
||||||
|
anchors.fill: parent
|
||||||
|
}
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
id: displayColumn
|
id: displayColumn
|
||||||
|
@@ -84,6 +84,7 @@ public:
|
|||||||
bool m_delayedDelete;
|
bool m_delayedDelete;
|
||||||
QTimer m_noDebugOutputTimer;
|
QTimer m_noDebugOutputTimer;
|
||||||
QmlJsDebugClient::QDeclarativeOutputParser m_outputParser;
|
QmlJsDebugClient::QDeclarativeOutputParser m_outputParser;
|
||||||
|
QTimer m_runningTimer;
|
||||||
};
|
};
|
||||||
|
|
||||||
AbstractQmlProfilerRunner *
|
AbstractQmlProfilerRunner *
|
||||||
@@ -153,6 +154,9 @@ QmlProfilerEngine::QmlProfilerEngine(IAnalyzerTool *tool,
|
|||||||
this, SLOT(processIsRunning()));
|
this, SLOT(processIsRunning()));
|
||||||
connect(&d->m_outputParser, SIGNAL(errorMessage(QString)),
|
connect(&d->m_outputParser, SIGNAL(errorMessage(QString)),
|
||||||
this, SLOT(wrongSetupMessageBox(QString)));
|
this, SLOT(wrongSetupMessageBox(QString)));
|
||||||
|
|
||||||
|
d->m_runningTimer.setInterval(100); // ten times per second
|
||||||
|
connect(&d->m_runningTimer, SIGNAL(timeout()), this, SIGNAL(timeUpdate()));
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlProfilerEngine::~QmlProfilerEngine()
|
QmlProfilerEngine::~QmlProfilerEngine()
|
||||||
@@ -201,6 +205,7 @@ bool QmlProfilerEngine::start()
|
|||||||
|
|
||||||
d->m_running = true;
|
d->m_running = true;
|
||||||
d->m_delayedDelete = false;
|
d->m_delayedDelete = false;
|
||||||
|
d->m_runningTimer.start();
|
||||||
|
|
||||||
if (d->m_fetchDataFromStart) {
|
if (d->m_fetchDataFromStart) {
|
||||||
d->m_fetchingData = true;
|
d->m_fetchingData = true;
|
||||||
@@ -236,6 +241,7 @@ void QmlProfilerEngine::stopped()
|
|||||||
}
|
}
|
||||||
|
|
||||||
d->m_running = false;
|
d->m_running = false;
|
||||||
|
d->m_runningTimer.stop();
|
||||||
AnalyzerManager::stopTool(); // FIXME: Needed?
|
AnalyzerManager::stopTool(); // FIXME: Needed?
|
||||||
emit finished();
|
emit finished();
|
||||||
}
|
}
|
||||||
@@ -259,6 +265,7 @@ void QmlProfilerEngine::finishProcess()
|
|||||||
// user stop?
|
// user stop?
|
||||||
if (d->m_running) {
|
if (d->m_running) {
|
||||||
d->m_running = false;
|
d->m_running = false;
|
||||||
|
d->m_runningTimer.stop();
|
||||||
if (d->m_runner)
|
if (d->m_runner)
|
||||||
d->m_runner->stop();
|
d->m_runner->stop();
|
||||||
emit finished();
|
emit finished();
|
||||||
@@ -290,6 +297,7 @@ void QmlProfilerEngine::wrongSetupMessageBox(const QString &errorMessage)
|
|||||||
infoBox->show();
|
infoBox->show();
|
||||||
|
|
||||||
d->m_running = false;
|
d->m_running = false;
|
||||||
|
d->m_runningTimer.stop();
|
||||||
AnalyzerManager::stopTool();
|
AnalyzerManager::stopTool();
|
||||||
emit finished();
|
emit finished();
|
||||||
}
|
}
|
||||||
|
@@ -53,6 +53,7 @@ public:
|
|||||||
signals:
|
signals:
|
||||||
void processRunning(int port);
|
void processRunning(int port);
|
||||||
void stopRecording();
|
void stopRecording();
|
||||||
|
void timeUpdate();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
bool start();
|
bool start();
|
||||||
|
@@ -117,6 +117,10 @@ public:
|
|||||||
QToolButton *m_clearButton;
|
QToolButton *m_clearButton;
|
||||||
bool m_recordingEnabled;
|
bool m_recordingEnabled;
|
||||||
bool m_appIsRunning;
|
bool m_appIsRunning;
|
||||||
|
bool m_qmlActive;
|
||||||
|
bool m_v8Active;
|
||||||
|
QTime m_appTimer;
|
||||||
|
qint64 m_appRunningTime;
|
||||||
|
|
||||||
enum ConnectMode {
|
enum ConnectMode {
|
||||||
TcpConnection, OstConnection
|
TcpConnection, OstConnection
|
||||||
@@ -141,6 +145,8 @@ QmlProfilerTool::QmlProfilerTool(QObject *parent)
|
|||||||
d->m_isAttached = false;
|
d->m_isAttached = false;
|
||||||
d->m_recordingEnabled = true;
|
d->m_recordingEnabled = true;
|
||||||
d->m_appIsRunning = false;
|
d->m_appIsRunning = false;
|
||||||
|
d->m_appTimer.start();
|
||||||
|
d->m_appRunningTime = 0;
|
||||||
|
|
||||||
d->m_connectionTimer.setInterval(200);
|
d->m_connectionTimer.setInterval(200);
|
||||||
connect(&d->m_connectionTimer, SIGNAL(timeout()), SLOT(tryToConnect()));
|
connect(&d->m_connectionTimer, SIGNAL(timeout()), SLOT(tryToConnect()));
|
||||||
@@ -337,8 +343,9 @@ IAnalyzerEngine *QmlProfilerTool::createEngine(const AnalyzerStartParameters &sp
|
|||||||
|
|
||||||
connect(engine, SIGNAL(processRunning(int)), this, SLOT(connectClient(int)));
|
connect(engine, SIGNAL(processRunning(int)), this, SLOT(connectClient(int)));
|
||||||
connect(engine, SIGNAL(finished()), this, SLOT(disconnectClient()));
|
connect(engine, SIGNAL(finished()), this, SLOT(disconnectClient()));
|
||||||
connect(engine, SIGNAL(finished()), this, SLOT(correctTimer()));
|
connect(engine, SIGNAL(finished()), this, SLOT(updateTimers()));
|
||||||
connect(engine, SIGNAL(stopRecording()), this, SLOT(stopRecording()));
|
connect(engine, SIGNAL(stopRecording()), this, SLOT(stopRecording()));
|
||||||
|
connect(engine, SIGNAL(timeUpdate()), this, SLOT(updateTimers()));
|
||||||
connect(d->m_traceWindow, SIGNAL(viewUpdated()), engine, SLOT(dataReceived()));
|
connect(d->m_traceWindow, SIGNAL(viewUpdated()), engine, SLOT(dataReceived()));
|
||||||
connect(this, SIGNAL(connectionFailed()), engine, SLOT(finishProcess()));
|
connect(this, SIGNAL(connectionFailed()), engine, SLOT(finishProcess()));
|
||||||
connect(this, SIGNAL(fetchingData(bool)), engine, SLOT(setFetchingData(bool)));
|
connect(this, SIGNAL(fetchingData(bool)), engine, SLOT(setFetchingData(bool)));
|
||||||
@@ -364,10 +371,11 @@ QWidget *QmlProfilerTool::createWidgets()
|
|||||||
d->m_traceWindow->reset(d->m_client);
|
d->m_traceWindow->reset(d->m_client);
|
||||||
|
|
||||||
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)));
|
|
||||||
connect(d->m_traceWindow, SIGNAL(contextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint)));
|
connect(d->m_traceWindow, SIGNAL(contextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint)));
|
||||||
connect(d->m_traceWindow->getEventList(), SIGNAL(error(QString)), this, SLOT(showErrorDialog(QString)));
|
connect(d->m_traceWindow->getEventList(), SIGNAL(error(QString)), this, SLOT(showErrorDialog(QString)));
|
||||||
connect(d->m_traceWindow->getEventList(), SIGNAL(dataReady()), this, SLOT(showSaveOption()));
|
connect(d->m_traceWindow->getEventList(), SIGNAL(dataReady()), this, SLOT(showSaveOption()));
|
||||||
|
connect(d->m_traceWindow->getEventList(), SIGNAL(dataReady()), this, SLOT(updateTimers()));
|
||||||
|
connect(d->m_traceWindow, SIGNAL(profilerStateChanged(bool,bool)), this, SLOT(profilerStateChanged(bool,bool)));
|
||||||
|
|
||||||
d->m_eventsView = new QmlProfilerEventsWidget(d->m_traceWindow->getEventList(), mw);
|
d->m_eventsView = new QmlProfilerEventsWidget(d->m_traceWindow->getEventList(), mw);
|
||||||
connect(d->m_eventsView, SIGNAL(gotoSourceLocation(QString,int)), this, SLOT(gotoSourceLocation(QString,int)));
|
connect(d->m_eventsView, SIGNAL(gotoSourceLocation(QString,int)), this, SLOT(gotoSourceLocation(QString,int)));
|
||||||
@@ -419,14 +427,14 @@ QWidget *QmlProfilerTool::createWidgets()
|
|||||||
connect(d->m_clearButton,SIGNAL(clicked()), this, SLOT(clearDisplay()));
|
connect(d->m_clearButton,SIGNAL(clicked()), this, SLOT(clearDisplay()));
|
||||||
layout->addWidget(d->m_clearButton);
|
layout->addWidget(d->m_clearButton);
|
||||||
|
|
||||||
QLabel *timeLabel = new QLabel(tr("Elapsed: 0 s"));
|
QLabel *timeLabel = new QLabel();
|
||||||
QPalette palette = timeLabel->palette();
|
QPalette palette = timeLabel->palette();
|
||||||
palette.setColor(QPalette::WindowText, Qt::white);
|
palette.setColor(QPalette::WindowText, Qt::white);
|
||||||
timeLabel->setPalette(palette);
|
timeLabel->setPalette(palette);
|
||||||
timeLabel->setIndent(10);
|
timeLabel->setIndent(10);
|
||||||
connect(d->m_traceWindow, SIGNAL(viewUpdated()), this, SLOT(correctTimer()));
|
connect(d->m_traceWindow, SIGNAL(viewUpdated()), this, SLOT(updateTimers()));
|
||||||
connect(this, SIGNAL(setTimeLabel(QString)), timeLabel, SLOT(setText(QString)));
|
connect(this, SIGNAL(setTimeLabel(QString)), timeLabel, SLOT(setText(QString)));
|
||||||
correctTimer();
|
updateTimers();
|
||||||
layout->addWidget(timeLabel);
|
layout->addWidget(timeLabel);
|
||||||
|
|
||||||
toolbarWidget->setLayout(layout);
|
toolbarWidget->setLayout(layout);
|
||||||
@@ -442,6 +450,7 @@ void QmlProfilerTool::connectClient(int port)
|
|||||||
connect(d->m_client, SIGNAL(stateChanged(QAbstractSocket::SocketState)),
|
connect(d->m_client, SIGNAL(stateChanged(QAbstractSocket::SocketState)),
|
||||||
this, SLOT(connectionStateChanged()));
|
this, SLOT(connectionStateChanged()));
|
||||||
d->m_connectionTimer.start();
|
d->m_connectionTimer.start();
|
||||||
|
d->m_appTimer.start();
|
||||||
d->m_tcpPort = port;
|
d->m_tcpPort = port;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -501,16 +510,20 @@ void QmlProfilerTool::setRecording(bool recording)
|
|||||||
startRecording();
|
startRecording();
|
||||||
else
|
else
|
||||||
stopRecording();
|
stopRecording();
|
||||||
|
|
||||||
|
updateTimers();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlProfilerTool::setAppIsRunning()
|
void QmlProfilerTool::setAppIsRunning()
|
||||||
{
|
{
|
||||||
d->m_appIsRunning = true;
|
d->m_appIsRunning = true;
|
||||||
|
updateTimers();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlProfilerTool::setAppIsStopped()
|
void QmlProfilerTool::setAppIsStopped()
|
||||||
{
|
{
|
||||||
d->m_appIsRunning = false;
|
d->m_appIsRunning = false;
|
||||||
|
updateTimers();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlProfilerTool::gotoSourceLocation(const QString &fileUrl, int lineNumber)
|
void QmlProfilerTool::gotoSourceLocation(const QString &fileUrl, int lineNumber)
|
||||||
@@ -535,23 +548,33 @@ void QmlProfilerTool::gotoSourceLocation(const QString &fileUrl, int lineNumber)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlProfilerTool::correctTimer() {
|
inline QString stringifyTime(double seconds)
|
||||||
if (d->m_traceWindow->getEventList()->count() == 0)
|
{
|
||||||
updateTimer(0);
|
QString timeString = QString::number(seconds,'f',1);
|
||||||
|
return QmlProfilerTool::tr("%1 s").arg(timeString, 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlProfilerTool::updateTimer(qreal elapsedSeconds)
|
void QmlProfilerTool::updateTimers()
|
||||||
{
|
{
|
||||||
QString timeString = QString::number(elapsedSeconds,'f',1);
|
// prof time
|
||||||
timeString = QString(" ").left(6-timeString.length()) + timeString;
|
QString profilerTimeStr = stringifyTime(d->m_traceWindow->profiledTime());
|
||||||
emit setTimeLabel(tr("Elapsed: %1 s").arg(timeString));
|
emit setTimeLabel(tr("Elapsed: %1").arg(profilerTimeStr));
|
||||||
|
}
|
||||||
|
|
||||||
|
void QmlProfilerTool::profilerStateChanged(bool qmlActive, bool v8active)
|
||||||
|
{
|
||||||
|
d->m_v8Active = v8active;
|
||||||
|
d->m_qmlActive = qmlActive;
|
||||||
|
updateTimers();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlProfilerTool::clearDisplay()
|
void QmlProfilerTool::clearDisplay()
|
||||||
{
|
{
|
||||||
|
d->m_appRunningTime = 0;
|
||||||
d->m_traceWindow->clearDisplay();
|
d->m_traceWindow->clearDisplay();
|
||||||
d->m_eventsView->clear();
|
d->m_eventsView->clear();
|
||||||
d->m_v8profilerView->clear();
|
d->m_v8profilerView->clear();
|
||||||
|
updateTimers();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void startRemoteTool(IAnalyzerTool *tool, StartMode mode)
|
static void startRemoteTool(IAnalyzerTool *tool, StartMode mode)
|
||||||
@@ -675,6 +698,8 @@ void QmlProfilerTool::updateRecordingState()
|
|||||||
|
|
||||||
if (d->m_traceWindow->isRecording())
|
if (d->m_traceWindow->isRecording())
|
||||||
clearDisplay();
|
clearDisplay();
|
||||||
|
|
||||||
|
updateTimers();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlProfilerTool::startTool(StartMode mode)
|
void QmlProfilerTool::startTool(StartMode mode)
|
||||||
|
@@ -76,8 +76,8 @@ public slots:
|
|||||||
void setAppIsStopped();
|
void setAppIsStopped();
|
||||||
|
|
||||||
void gotoSourceLocation(const QString &fileUrl, int lineNumber);
|
void gotoSourceLocation(const QString &fileUrl, int lineNumber);
|
||||||
void updateTimer(qreal elapsedSeconds);
|
void updateTimers();
|
||||||
void correctTimer();
|
void profilerStateChanged(bool qmlActive, bool v8active);
|
||||||
|
|
||||||
void clearDisplay();
|
void clearDisplay();
|
||||||
|
|
||||||
@@ -85,6 +85,7 @@ public slots:
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
void setTimeLabel(const QString &);
|
void setTimeLabel(const QString &);
|
||||||
|
void setStatusLabel(const QString &);
|
||||||
void fetchingData(bool);
|
void fetchingData(bool);
|
||||||
void connectionFailed();
|
void connectionFailed();
|
||||||
void cancelRun();
|
void cancelRun();
|
||||||
|
@@ -146,10 +146,12 @@ TraceWindow::TraceWindow(QWidget *parent)
|
|||||||
// Minimum height: 5 rows of 20 pixels + scrollbar of 50 pixels + 20 pixels margin
|
// Minimum height: 5 rows of 20 pixels + scrollbar of 50 pixels + 20 pixels margin
|
||||||
setMinimumHeight(170);
|
setMinimumHeight(170);
|
||||||
m_currentZoomLevel = 0;
|
m_currentZoomLevel = 0;
|
||||||
|
m_profiledTime = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
TraceWindow::~TraceWindow()
|
TraceWindow::~TraceWindow()
|
||||||
{
|
{
|
||||||
|
disconnectClientSignals();
|
||||||
delete m_plugin.data();
|
delete m_plugin.data();
|
||||||
delete m_v8plugin.data();
|
delete m_v8plugin.data();
|
||||||
}
|
}
|
||||||
@@ -258,24 +260,14 @@ QWidget *TraceWindow::createZoomToolbar()
|
|||||||
|
|
||||||
void TraceWindow::reset(QDeclarativeDebugConnection *conn)
|
void TraceWindow::reset(QDeclarativeDebugConnection *conn)
|
||||||
{
|
{
|
||||||
if (m_plugin)
|
disconnectClientSignals();
|
||||||
disconnect(m_plugin.data(), SIGNAL(complete()), this, SLOT(qmlComplete()));
|
|
||||||
delete m_plugin.data();
|
delete m_plugin.data();
|
||||||
m_plugin = new QmlProfilerTraceClient(conn);
|
m_plugin = new QmlProfilerTraceClient(conn);
|
||||||
connect(m_plugin.data(), SIGNAL(complete()), this, SLOT(qmlComplete()));
|
|
||||||
connect(m_plugin.data(), SIGNAL(range(int,qint64,qint64,QStringList,QString,int)),
|
|
||||||
this, SIGNAL(range(int,qint64,qint64,QStringList,QString,int)));
|
|
||||||
|
|
||||||
if (m_v8plugin) {
|
|
||||||
disconnect(m_v8plugin.data(), SIGNAL(complete()), this, SLOT(v8Complete()));
|
|
||||||
disconnect(m_v8plugin.data(), SIGNAL(v8range(int,QString,QString,int,double,double)), this, SIGNAL(v8range(int,QString,QString,int,double,double)));
|
|
||||||
}
|
|
||||||
delete m_v8plugin.data();
|
delete m_v8plugin.data();
|
||||||
m_v8plugin = new QV8ProfilerClient(conn);
|
m_v8plugin = new QV8ProfilerClient(conn);
|
||||||
connect(m_v8plugin.data(), SIGNAL(complete()), this, SLOT(v8Complete()));
|
|
||||||
connect(m_v8plugin.data(), SIGNAL(v8range(int,QString,QString,int,double,double)), this, SIGNAL(v8range(int,QString,QString,int,double,double)));
|
connectClientSignals();
|
||||||
connect(m_plugin.data(), SIGNAL(traceFinished(qint64)), this, SIGNAL(traceFinished(qint64)));
|
|
||||||
connect(m_plugin.data(), SIGNAL(traceStarted(qint64)), this, SIGNAL(traceStarted(qint64)));
|
|
||||||
|
|
||||||
m_mainView->rootContext()->setContextProperty("connection", m_plugin.data());
|
m_mainView->rootContext()->setContextProperty("connection", m_plugin.data());
|
||||||
m_mainView->rootContext()->setContextProperty("zoomControl", m_zoomControl.data());
|
m_mainView->rootContext()->setContextProperty("zoomControl", m_zoomControl.data());
|
||||||
@@ -311,6 +303,40 @@ void TraceWindow::reset(QDeclarativeDebugConnection *conn)
|
|||||||
m_qmlDataReady = false;
|
m_qmlDataReady = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TraceWindow::connectClientSignals()
|
||||||
|
{
|
||||||
|
if (m_plugin) {
|
||||||
|
connect(m_plugin.data(), SIGNAL(complete()), this, SLOT(qmlComplete()));
|
||||||
|
connect(m_plugin.data(), SIGNAL(range(int,qint64,qint64,QStringList,QString,int)),
|
||||||
|
this, SIGNAL(range(int,qint64,qint64,QStringList,QString,int)));
|
||||||
|
connect(m_plugin.data(), SIGNAL(traceFinished(qint64)), this, SIGNAL(traceFinished(qint64)));
|
||||||
|
connect(m_plugin.data(), SIGNAL(traceStarted(qint64)), this, SIGNAL(traceStarted(qint64)));
|
||||||
|
connect(m_plugin.data(), SIGNAL(enabledChanged()), this, SLOT(updateProfilerState()));
|
||||||
|
}
|
||||||
|
if (m_v8plugin) {
|
||||||
|
connect(m_v8plugin.data(), SIGNAL(complete()), this, SLOT(v8Complete()));
|
||||||
|
connect(m_v8plugin.data(), SIGNAL(v8range(int,QString,QString,int,double,double)), this, SIGNAL(v8range(int,QString,QString,int,double,double)));
|
||||||
|
connect(m_v8plugin.data(), SIGNAL(enabledChanged()), this, SLOT(updateProfilerState()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TraceWindow::disconnectClientSignals()
|
||||||
|
{
|
||||||
|
if (m_plugin) {
|
||||||
|
disconnect(m_plugin.data(), SIGNAL(complete()), this, SLOT(qmlComplete()));
|
||||||
|
disconnect(m_plugin.data(), SIGNAL(range(int,qint64,qint64,QStringList,QString,int)),
|
||||||
|
this, SIGNAL(range(int,qint64,qint64,QStringList,QString,int)));
|
||||||
|
disconnect(m_plugin.data(), SIGNAL(traceFinished(qint64)), this, SIGNAL(traceFinished(qint64)));
|
||||||
|
disconnect(m_plugin.data(), SIGNAL(traceStarted(qint64)), this, SIGNAL(traceStarted(qint64)));
|
||||||
|
disconnect(m_plugin.data(), SIGNAL(enabledChanged()), this, SLOT(updateProfilerState()));
|
||||||
|
}
|
||||||
|
if (m_v8plugin) {
|
||||||
|
disconnect(m_v8plugin.data(), SIGNAL(complete()), this, SLOT(v8Complete()));
|
||||||
|
disconnect(m_v8plugin.data(), SIGNAL(v8range(int,QString,QString,int,double,double)), this, SIGNAL(v8range(int,QString,QString,int,double,double)));
|
||||||
|
disconnect(m_v8plugin.data(), SIGNAL(enabledChanged()), this, SLOT(updateProfilerState()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QmlProfilerEventList *TraceWindow::getEventList() const
|
QmlProfilerEventList *TraceWindow::getEventList() const
|
||||||
{
|
{
|
||||||
return m_eventList;
|
return m_eventList;
|
||||||
@@ -334,7 +360,12 @@ void TraceWindow::updateCursorPosition()
|
|||||||
|
|
||||||
void TraceWindow::updateTimer()
|
void TraceWindow::updateTimer()
|
||||||
{
|
{
|
||||||
emit timeChanged(m_mainView->rootObject()->property("elapsedTime").toDouble());
|
m_profiledTime = m_mainView->rootObject()->property("elapsedTime").toDouble();
|
||||||
|
}
|
||||||
|
|
||||||
|
double TraceWindow::profiledTime() const
|
||||||
|
{
|
||||||
|
return m_profiledTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TraceWindow::clearDisplay()
|
void TraceWindow::clearDisplay()
|
||||||
@@ -347,6 +378,7 @@ void TraceWindow::clearDisplay()
|
|||||||
m_v8plugin.data()->clearData();
|
m_v8plugin.data()->clearData();
|
||||||
|
|
||||||
m_zoomControl.data()->setRange(0,0);
|
m_zoomControl.data()->setRange(0,0);
|
||||||
|
m_profiledTime = 0;
|
||||||
|
|
||||||
emit internalClearDisplay();
|
emit internalClearDisplay();
|
||||||
}
|
}
|
||||||
@@ -513,5 +545,17 @@ void TraceWindow::selectNextEvent(int eventId)
|
|||||||
emit selectNextEventInDisplay(QVariant(eventId));
|
emit selectNextEventInDisplay(QVariant(eventId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TraceWindow::updateProfilerState()
|
||||||
|
{
|
||||||
|
bool qmlActive = false;
|
||||||
|
bool v8Active = false;
|
||||||
|
if (m_plugin)
|
||||||
|
qmlActive = m_plugin.data()->isEnabled();
|
||||||
|
if (m_v8plugin)
|
||||||
|
v8Active = m_v8plugin.data()->isEnabled();
|
||||||
|
|
||||||
|
emit profilerStateChanged(qmlActive, v8Active);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace QmlProfiler
|
} // namespace QmlProfiler
|
||||||
|
@@ -107,6 +107,7 @@ public:
|
|||||||
bool hasValidSelection() const;
|
bool hasValidSelection() const;
|
||||||
qint64 selectionStart() const;
|
qint64 selectionStart() const;
|
||||||
qint64 selectionEnd() const;
|
qint64 selectionEnd() const;
|
||||||
|
double profiledTime() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void updateCursorPosition();
|
void updateCursorPosition();
|
||||||
@@ -124,11 +125,12 @@ public slots:
|
|||||||
void qmlComplete();
|
void qmlComplete();
|
||||||
void v8Complete();
|
void v8Complete();
|
||||||
void selectNextEvent(int eventId);
|
void selectNextEvent(int eventId);
|
||||||
|
void updateProfilerState();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void viewUpdated();
|
void viewUpdated();
|
||||||
|
void profilerStateChanged(bool qmlActive, bool v8active);
|
||||||
void gotoSourceLocation(const QString &fileUrl, int lineNumber);
|
void gotoSourceLocation(const QString &fileUrl, int lineNumber);
|
||||||
void timeChanged(qreal newTime);
|
|
||||||
void range(int type, qint64 startTime, qint64 length, const QStringList &data, const QString &fileName, int line);
|
void range(int type, qint64 startTime, qint64 length, const QStringList &data, const QString &fileName, int line);
|
||||||
void v8range(int depth,const QString &function,const QString &filename,
|
void v8range(int depth,const QString &function,const QString &filename,
|
||||||
int lineNumber, double totalTime, double selfTime);
|
int lineNumber, double totalTime, double selfTime);
|
||||||
@@ -154,6 +156,8 @@ private:
|
|||||||
void contextMenuEvent(QContextMenuEvent *);
|
void contextMenuEvent(QContextMenuEvent *);
|
||||||
QWidget *createToolbar();
|
QWidget *createToolbar();
|
||||||
QWidget *createZoomToolbar();
|
QWidget *createZoomToolbar();
|
||||||
|
void connectClientSignals();
|
||||||
|
void disconnectClientSignals();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void resizeEvent(QResizeEvent *event);
|
virtual void resizeEvent(QResizeEvent *event);
|
||||||
@@ -169,6 +173,7 @@ private:
|
|||||||
QmlJsDebugClient::QmlProfilerEventList *m_eventList;
|
QmlJsDebugClient::QmlProfilerEventList *m_eventList;
|
||||||
bool m_qmlDataReady;
|
bool m_qmlDataReady;
|
||||||
bool m_v8DataReady;
|
bool m_v8DataReady;
|
||||||
|
double m_profiledTime;
|
||||||
|
|
||||||
QWeakPointer<ZoomControl> m_zoomControl;
|
QWeakPointer<ZoomControl> m_zoomControl;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user