Commit bc4d15f3 authored by Christiaan Janssen's avatar Christiaan Janssen
Browse files

QmlProfiler: use end of trace event if present

Change-Id: I149a05500fd4bc722da3c409491b35304155828b
Reviewed-on: http://codereview.qt-project.org/6436


Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarKai Koehne <kai.koehne@nokia.com>
parent aa3d406f
......@@ -190,7 +190,6 @@ QmlProfilerEventList::QmlProfilerEventList(QObject *parent) :
d->m_parsingStatus = DoneStatus;
setObjectName("QmlProfilerEventStatistics");
// todo: read from client
d->m_traceEndTime = 0;
}
......@@ -212,6 +211,7 @@ void QmlProfilerEventList::clear()
d->m_v8EventList.clear();
d->m_v8parents.clear();
d->m_traceEndTime = 0;
emit countChanged();
}
......@@ -350,6 +350,11 @@ void QmlProfilerEventList::QmlProfilerEventListPrivate::collectV8Statistics()
}
}
void QmlProfilerEventList::setTraceEndTime( qint64 time )
{
d->m_traceEndTime = time;
}
void QmlProfilerEventList::complete()
{
d->collectV8Statistics();
......
......@@ -140,6 +140,8 @@ public slots:
void setFilename(const QString &filename);
void load();
void setTraceEndTime( qint64 time );
private slots:
void postProcess();
void sortEndTimes();
......
......@@ -137,7 +137,10 @@ void QmlProfilerTraceClient::messageReceived(const QByteArray &data)
int event;
stream >> event;
if (event < MaximumEventType) {
if (event == EndTrace) {
emit this->traceFinished(time);
d->maximumTime = time;
} else if (event < MaximumEventType) {
emit this->event((EventType)event, time);
d->maximumTime = qMax(time, d->maximumTime);
}
......
......@@ -66,6 +66,8 @@ public:
FramePaint,
Mouse,
Key,
AnimationFrame,
EndTrace,
MaximumEventType
};
......@@ -91,6 +93,7 @@ signals:
void complete();
void gap(qint64 time);
void event(int event, qint64 time);
void traceFinished( qint64 time );
void range(int type, qint64 startTime, qint64 length,
const QStringList &data, const QString &fileName, int line);
......
......@@ -68,7 +68,7 @@ function drawData(canvas, ctxt, region)
var width = canvas.canvasSize.width - xmargin;
var height = canvas.height - ymargin;
var sumValue = qmlEventList.lastTimeMark() - qmlEventList.firstTimeMark();
var sumValue = qmlEventList.traceEndTime() - qmlEventList.traceStartTime();
var spacing = width / sumValue;
ctxt.fillStyle = "rgba(0,0,0,1)";
......@@ -77,7 +77,7 @@ function drawData(canvas, ctxt, region)
//### only draw those in range
for (var ii = 0; ii < qmlEventList.count(); ++ii) {
var xx = (qmlEventList.getStartTime(ii) - qmlEventList.firstTimeMark()) * spacing + xmargin;
var xx = (qmlEventList.getStartTime(ii) - qmlEventList.traceStartTime()) * spacing + xmargin;
if (xx > region.x + region.width)
continue;
......@@ -110,7 +110,7 @@ function xScale(canvas)
var width = canvas.canvasSize.width - xmargin;
var sumValue = qmlEventList.lastTimeMark() - qmlEventList.firstTimeMark();
var sumValue = qmlEventList.traceEndTime() - qmlEventList.traceStartTime();
var spacing = sumValue / width;
return spacing;
}
......@@ -84,7 +84,7 @@ Rectangle {
&& selectedEventIndex > -1 && selectedEventIndex < eventCount) {
// re-center flickable if necessary
var xs = Plotter.xScale(canvas);
var startTime = qmlEventList.firstTimeMark();
var startTime = qmlEventList.traceStartTime();
var eventStartTime = qmlEventList.getStartTime(selectedEventIndex);
var eventDuration = qmlEventList.getDuration(selectedEventIndex);
if (rangeMover.value + startTime > eventStartTime) {
......@@ -146,7 +146,7 @@ Rectangle {
root.clearAll();
if (eventCount > 1) {
root.progress = Math.min(1.0,
(qmlEventList.lastTimeMark() - qmlEventList.firstTimeMark()) / root.elapsedTime * 1e-9 ) * 0.5;
(qmlEventList.traceEndTime() - qmlEventList.traceStartTime()) / root.elapsedTime * 1e-9 ) * 0.5;
} else
root.progress = 0;
}
......@@ -191,8 +191,8 @@ Rectangle {
height: flick.height + labels.y
anchors.left: flick.left
anchors.right: flick.right
startTime: rangeMover.x * Plotter.xScale(canvas) + qmlEventList.firstTimeMark();
endTime: (rangeMover.x + rangeMover.zoomWidth) * Plotter.xScale(canvas) + qmlEventList.firstTimeMark();
startTime: rangeMover.x * Plotter.xScale(canvas) + qmlEventList.traceStartTime();
endTime: (rangeMover.x + rangeMover.zoomWidth) * Plotter.xScale(canvas) + qmlEventList.traceStartTime();
}
function hideRangeDetails() {
......
......@@ -106,6 +106,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(viewUpdated()), m_eventList, SLOT(complete()));
m_view->rootContext()->setContextProperty("qmlEventList", m_eventList);
......@@ -139,6 +140,7 @@ void TraceWindow::reset(QDeclarativeDebugConnection *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)));
connect(m_plugin.data(), SIGNAL(traceFinished(qint64)), this, SIGNAL(traceFinished(qint64)));
m_view->rootContext()->setContextProperty("connection", m_plugin.data());
m_view->setSource(QUrl("qrc:/qmlprofiler/MainView.qml"));
......
......@@ -78,9 +78,9 @@ signals:
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 v8range(int depth,const QString &function,const QString &filename,
int lineNumber, double totalTime, double selfTime);
void traceFinished(qint64);
void internalClearDisplay();
void jumpToPrev();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment