QmlProfiler: nonzero trace starttimes

Change-Id: I734c1af79a4975f5f331f212721331ea877b391a
Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
This commit is contained in:
Christiaan Janssen
2011-11-02 16:57:31 +01:00
parent 2b8e8cd8df
commit 886e613572
10 changed files with 54 additions and 23 deletions

View File

@@ -181,6 +181,7 @@ public:
QHash<int, QmlEventTypeCount *> 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;

View File

@@ -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();

View File

@@ -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);

View File

@@ -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);

View File

@@ -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;
}

View File

@@ -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];

View File

@@ -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;
}

View File

@@ -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

View File

@@ -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);

View File

@@ -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();