diff --git a/src/libs/qmljsdebugclient/qmlprofilereventlist.cpp b/src/libs/qmljsdebugclient/qmlprofilereventlist.cpp index 370c13fbbc2..d81359858ff 100644 --- a/src/libs/qmljsdebugclient/qmlprofilereventlist.cpp +++ b/src/libs/qmljsdebugclient/qmlprofilereventlist.cpp @@ -181,6 +181,7 @@ public: QHash m_typeCounts; qint64 m_traceEndTime; + qint64 m_traceStartTime; // file to load QString m_filename; @@ -198,6 +199,7 @@ QmlProfilerEventList::QmlProfilerEventList(QObject *parent) : setObjectName("QmlProfilerEventStatistics"); d->m_traceEndTime = 0; + d->m_traceStartTime = 0; } QmlProfilerEventList::~QmlProfilerEventList() @@ -223,6 +225,7 @@ void QmlProfilerEventList::clear() d->m_typeCounts.clear(); d->m_traceEndTime = 0; + d->m_traceStartTime = 0; emit countChanged(); emit dataClear(); } @@ -367,6 +370,11 @@ void QmlProfilerEventList::setTraceEndTime( qint64 time ) d->m_traceEndTime = time; } +void QmlProfilerEventList::setTraceStartTime( qint64 time ) +{ + d->m_traceStartTime = time; +} + void QmlProfilerEventList::complete() { d->collectV8Statistics(); @@ -800,7 +808,7 @@ qint64 QmlProfilerEventList::lastTimeMark() const qint64 QmlProfilerEventList::traceStartTime() const { - return 0; + return d->m_traceStartTime; } qint64 QmlProfilerEventList::traceEndTime() const @@ -808,6 +816,11 @@ qint64 QmlProfilerEventList::traceEndTime() const return d->m_traceEndTime ? d->m_traceEndTime : lastTimeMark(); } +qint64 QmlProfilerEventList::traceDuration() const +{ + return traceEndTime() - traceStartTime(); +} + int QmlProfilerEventList::count() const { return d->m_startTimeSortedList.count(); @@ -835,6 +848,9 @@ void QmlProfilerEventList::save(const QString &filename) stream.writeStartElement("trace"); + stream.writeAttribute("traceStart", QString::number(traceStartTime())); + stream.writeAttribute("traceEnd", QString::number(traceEndTime())); + stream.writeStartElement("eventData"); foreach (const QmlEventData *eventData, d->m_eventDescriptions.values()) { stream.writeStartElement("event"); @@ -936,6 +952,13 @@ void QmlProfilerEventList::load() switch (token) { case QXmlStreamReader::StartDocument : continue; case QXmlStreamReader::StartElement : { + if (elementName == "trace") { + QXmlStreamAttributes attributes = stream.attributes(); + if (attributes.hasAttribute("traceStart")) + setTraceStartTime(attributes.value("traceStart").toString().toLongLong()); + if (attributes.hasAttribute("traceEnd")) + setTraceEndTime(attributes.value("traceEnd").toString().toLongLong()); + } if (elementName == "eventData" && !readingV8Events) { readingQmlEvents = true; break; diff --git a/src/libs/qmljsdebugclient/qmlprofilereventlist.h b/src/libs/qmljsdebugclient/qmlprofilereventlist.h index bac9f77bf38..64f3aa0bd3d 100644 --- a/src/libs/qmljsdebugclient/qmlprofilereventlist.h +++ b/src/libs/qmljsdebugclient/qmlprofilereventlist.h @@ -129,6 +129,7 @@ public: Q_INVOKABLE qint64 traceStartTime() const; Q_INVOKABLE qint64 traceEndTime() const; + Q_INVOKABLE qint64 traceDuration() const; void showErrorDialog(const QString &st ) const; signals: @@ -151,6 +152,7 @@ public slots: void load(); void setTraceEndTime( qint64 time ); + void setTraceStartTime( qint64 time ); private slots: void postProcess(); diff --git a/src/libs/qmljsdebugclient/qmlprofilertraceclient.cpp b/src/libs/qmljsdebugclient/qmlprofilertraceclient.cpp index 899873ef727..5153ed64afb 100644 --- a/src/libs/qmljsdebugclient/qmlprofilertraceclient.cpp +++ b/src/libs/qmljsdebugclient/qmlprofilertraceclient.cpp @@ -140,6 +140,9 @@ void QmlProfilerTraceClient::messageReceived(const QByteArray &data) if (event == EndTrace) { emit this->traceFinished(time); d->maximumTime = time; + } else if (event == StartTrace) { + emit this->traceStarted(time); + d->maximumTime = time; } else if (event < MaximumEventType) { emit this->event((EventType)event, time); d->maximumTime = qMax(time, d->maximumTime); diff --git a/src/libs/qmljsdebugclient/qmlprofilertraceclient.h b/src/libs/qmljsdebugclient/qmlprofilertraceclient.h index 10d21db9d5b..0de556a7b7c 100644 --- a/src/libs/qmljsdebugclient/qmlprofilertraceclient.h +++ b/src/libs/qmljsdebugclient/qmlprofilertraceclient.h @@ -68,6 +68,7 @@ public: Key, AnimationFrame, EndTrace, + StartTrace, MaximumEventType }; @@ -94,6 +95,7 @@ signals: void gap(qint64 time); void event(int event, qint64 time); void traceFinished( qint64 time ); + void traceStarted( qint64 time ); void range(int type, qint64 startTime, qint64 length, const QStringList &data, const QString &fileName, int line); diff --git a/src/plugins/qmlprofiler/qml/MainView.qml b/src/plugins/qmlprofiler/qml/MainView.qml index 1ba891631ee..adf61d2325f 100644 --- a/src/plugins/qmlprofiler/qml/MainView.qml +++ b/src/plugins/qmlprofiler/qml/MainView.qml @@ -79,7 +79,7 @@ Rectangle { backgroundMarks.updateMarks(startTime, endTime); view.updateFlickRange(startTime, endTime); if (duration > 0) { - var candidateWidth = qmlEventList.traceEndTime() * flick.width / duration; + var candidateWidth = qmlEventList.traceDuration() * flick.width / duration; if (flick.contentWidth !== candidateWidth) flick.contentWidth = candidateWidth; } @@ -112,7 +112,7 @@ Rectangle { dataAvailable = true; view.visible = true; view.requestPaint(); - zoomControl.setRange(0, qmlEventList.traceEndTime()/10); + zoomControl.setRange(qmlEventList.traceStartTime(), qmlEventList.traceStartTime() + qmlEventList.traceDuration()/10); } } } @@ -152,9 +152,9 @@ Rectangle { function updateWindowLength(absoluteFactor) { var windowLength = view.endTime - view.startTime; - if (qmlEventList.traceEndTime() <= 0 || windowLength <= 0) + if (qmlEventList.traceEndTime() <= qmlEventList.traceStartTime() || windowLength <= 0) return; - var currentFactor = windowLength / qmlEventList.traceEndTime(); + var currentFactor = windowLength / qmlEventList.traceDuration(); updateZoom(absoluteFactor / currentFactor); } @@ -165,8 +165,8 @@ Rectangle { windowLength = min_length; var newWindowLength = windowLength * relativeFactor; - if (newWindowLength > qmlEventList.traceEndTime()) { - newWindowLength = qmlEventList.traceEndTime(); + if (newWindowLength > qmlEventList.traceDuration()) { + newWindowLength = qmlEventList.traceDuration(); relativeFactor = newWindowLength / windowLength; } if (newWindowLength < min_length) { @@ -194,8 +194,8 @@ Rectangle { windowLength = min_length; var newWindowLength = windowLength * relativeFactor; - if (newWindowLength > qmlEventList.traceEndTime()) { - newWindowLength = qmlEventList.traceEndTime(); + if (newWindowLength > qmlEventList.traceDuration()) { + newWindowLength = qmlEventList.traceDuration(); relativeFactor = newWindowLength / windowLength; } if (newWindowLength < min_length) { @@ -223,7 +223,7 @@ Rectangle { } function wheelZoom(wheelCenter, wheelDelta) { - if (qmlEventList.traceEndTime()>0 && wheelDelta!=0) { + if (qmlEventList.traceEndTime() > qmlEventList.traceStartTime() && wheelDelta !== 0) { if (wheelDelta>0) updateZoomCentered(wheelCenter, 1/1.2); else @@ -339,9 +339,9 @@ Rectangle { property variant startX: 0 onStartXChanged: { - var newStartTime = Math.round(startX * (endTime - startTime) / flick.width); + var newStartTime = Math.round(startX * (endTime - startTime) / flick.width) + qmlEventList.traceStartTime(); if (Math.abs(newStartTime - startTime) > 1) { - var newEndTime = Math.round((startX+flick.width)* (endTime - startTime) / flick.width); + var newEndTime = Math.round((startX+flick.width)* (endTime - startTime) / flick.width) + qmlEventList.traceStartTime(); zoomControl.setRange(newStartTime, newEndTime); } @@ -353,7 +353,7 @@ Rectangle { if (start !== startTime || end !== endTime) { startTime = start; endTime = end; - var newStartX = startTime * flick.width / (endTime-startTime); + var newStartX = (startTime - qmlEventList.traceStartTime()) * flick.width / (endTime-startTime); if (Math.abs(newStartX - startX) >= 1) startX = newStartX; } diff --git a/src/plugins/qmlprofiler/qml/Overview.js b/src/plugins/qmlprofiler/qml/Overview.js index ba358e85736..ef9b66c164c 100644 --- a/src/plugins/qmlprofiler/qml/Overview.js +++ b/src/plugins/qmlprofiler/qml/Overview.js @@ -54,8 +54,7 @@ function drawData(canvas, ctxt, region) var width = canvas.width; var height = canvas.height; - var sumValue = qmlEventList.traceEndTime() - qmlEventList.traceStartTime(); - var spacing = width / sumValue; + var spacing = width / qmlEventList.traceDuration(); ctxt.fillStyle = "rgba(0,0,0,1)"; var highest = [0,0,0,0,0]; diff --git a/src/plugins/qmlprofiler/qml/Overview.qml b/src/plugins/qmlprofiler/qml/Overview.qml index 10ed9d25233..7ed28f62fe8 100644 --- a/src/plugins/qmlprofiler/qml/Overview.qml +++ b/src/plugins/qmlprofiler/qml/Overview.qml @@ -51,8 +51,8 @@ Canvas2D { } function updateRange() { - var newStartTime = Math.round(rangeMover.x * qmlEventList.traceEndTime() / width); - var newEndTime = Math.round((rangeMover.x + rangeMover.width) * qmlEventList.traceEndTime() / width); + var newStartTime = Math.round(rangeMover.x * qmlEventList.traceDuration() / width) + qmlEventList.traceStartTime(); + var newEndTime = Math.round((rangeMover.x + rangeMover.width) * qmlEventList.traceDuration() / width) + qmlEventList.traceStartTime(); if (startTime !== newStartTime || endTime !== newEndTime) { zoomControl.setRange(newStartTime, newEndTime); } @@ -65,10 +65,10 @@ Canvas2D { if (qmlEventList) { startTime = zoomControl.startTime(); endTime = zoomControl.endTime(); - var newRangeX = startTime * width / qmlEventList.traceEndTime(); + var newRangeX = (startTime - qmlEventList.traceStartTime()) * width / qmlEventList.traceDuration(); if (rangeMover.x !== newRangeX) rangeMover.x = newRangeX; - var newWidth = (endTime-startTime) * width / qmlEventList.traceEndTime(); + var newWidth = (endTime-startTime) * width / qmlEventList.traceDuration(); if (rangeMover.width !== newWidth) rangeMover.width = newWidth; } diff --git a/src/plugins/qmlprofiler/qml/SelectionRange.qml b/src/plugins/qmlprofiler/qml/SelectionRange.qml index b45d6b65e70..2c9c2eece3f 100644 --- a/src/plugins/qmlprofiler/qml/SelectionRange.qml +++ b/src/plugins/qmlprofiler/qml/SelectionRange.qml @@ -50,7 +50,7 @@ Rectangle { property string endTimeString: detailedPrintTime(startTime+duration) property string durationString: detailedPrintTime(duration) - property variant startTime: x * selectionRange.viewTimePerPixel + property variant startTime: x * selectionRange.viewTimePerPixel + qmlEventList.traceStartTime() property variant duration: width * selectionRange.viewTimePerPixel property variant viewTimePerPixel: 1 property variant creationState : 0 diff --git a/src/plugins/qmlprofiler/tracewindow.cpp b/src/plugins/qmlprofiler/tracewindow.cpp index 406590a557e..9696ad74541 100644 --- a/src/plugins/qmlprofiler/tracewindow.cpp +++ b/src/plugins/qmlprofiler/tracewindow.cpp @@ -117,6 +117,7 @@ TraceWindow::TraceWindow(QWidget *parent) m_eventList = new QmlProfilerEventList(this); connect(this,SIGNAL(range(int,qint64,qint64,QStringList,QString,int)), m_eventList, SLOT(addRangedEvent(int,qint64,qint64,QStringList,QString,int))); connect(this, SIGNAL(traceFinished(qint64)), m_eventList, SLOT(setTraceEndTime(qint64))); + connect(this, SIGNAL(traceStarted(qint64)), m_eventList, SLOT(setTraceStartTime(qint64))); connect(this,SIGNAL(viewUpdated()), m_eventList, SLOT(complete())); m_mainView->rootContext()->setContextProperty("qmlEventList", m_eventList); m_overview->rootContext()->setContextProperty("qmlEventList", m_eventList); @@ -256,6 +257,7 @@ void TraceWindow::reset(QDeclarativeDebugConnection *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))); 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("zoomControl", m_zoomControl.data()); @@ -448,10 +450,9 @@ void TraceWindow::updateRange() qreal duration = m_zoomControl.data()->endTime() - m_zoomControl.data()->startTime(); if (duration <= 0) return; - qreal totalTime = m_eventList->traceEndTime() - m_eventList->traceStartTime(); - if (totalTime <= 0) + if (m_eventList->traceDuration() <= 0) return; - int newLevel = pow(duration / totalTime, 1/sliderExp) * sliderTicks; + int newLevel = pow(duration / m_eventList->traceDuration(), 1/sliderExp) * sliderTicks; if (m_currentZoomLevel != newLevel) { m_currentZoomLevel = newLevel; emit zoomLevelChanged(newLevel); diff --git a/src/plugins/qmlprofiler/tracewindow.h b/src/plugins/qmlprofiler/tracewindow.h index 3ae9b017d2c..3642fde54c5 100644 --- a/src/plugins/qmlprofiler/tracewindow.h +++ b/src/plugins/qmlprofiler/tracewindow.h @@ -121,6 +121,7 @@ signals: void v8range(int depth,const QString &function,const QString &filename, int lineNumber, double totalTime, double selfTime); void traceFinished(qint64); + void traceStarted(qint64); void internalClearDisplay(); void jumpToPrev();