From 215c0533d20950d412e304dc41bc0bc93afac84f Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 28 Apr 2016 15:40:02 +0200 Subject: [PATCH] QmlProfiler: Rename QmlEvent::startTime to "timestamp" As many events are instantaneous and we're going to drop the duration property soon, this is more fitting. Change-Id: I6e13dd076a5b9df16aed44bf9f631ea5760e9cbf Reviewed-by: Joerg Bornemann --- .../qmlprofiler/debugmessagesmodel.cpp | 4 ++-- src/plugins/qmlprofiler/flamegraphmodel.cpp | 6 ++--- src/plugins/qmlprofiler/inputeventsmodel.cpp | 2 +- src/plugins/qmlprofiler/memoryusagemodel.cpp | 14 +++++------ src/plugins/qmlprofiler/pixmapcachemodel.cpp | 6 ++--- src/plugins/qmlprofiler/qmlevent.h | 20 ++++++++-------- .../qmlprofileranimationsmodel.cpp | 6 ++--- .../qmlprofiler/qmlprofilerdatamodel.cpp | 4 ++-- .../qmlprofiler/qmlprofilerrangemodel.cpp | 2 +- .../qmlprofilerstatisticsmodel.cpp | 24 +++++++++---------- .../qmlprofiler/qmlprofilertracefile.cpp | 5 ++-- .../qmlprofiler/scenegraphtimelinemodel.cpp | 18 +++++++------- 12 files changed, 55 insertions(+), 56 deletions(-) diff --git a/src/plugins/qmlprofiler/debugmessagesmodel.cpp b/src/plugins/qmlprofiler/debugmessagesmodel.cpp index 7ea435fdd2b..ae0dfd07448 100644 --- a/src/plugins/qmlprofiler/debugmessagesmodel.cpp +++ b/src/plugins/qmlprofiler/debugmessagesmodel.cpp @@ -109,10 +109,10 @@ void DebugMessagesModel::loadData() foreach (const QmlEvent &event, simpleModel->events()) { const QmlEventType &type = types[event.typeIndex()]; - if (!accepted(type) || event.startTime() < 0) + if (!accepted(type) || event.timestamp() < 0) continue; - m_data.insert(insert(event.startTime(), 0, type.detailType), + m_data.insert(insert(event.timestamp(), 0, type.detailType), MessageData(event.stringData(), event.typeIndex())); if (type.detailType > m_maximumMsgType) m_maximumMsgType = event.typeIndex(); diff --git a/src/plugins/qmlprofiler/flamegraphmodel.cpp b/src/plugins/qmlprofiler/flamegraphmodel.cpp index 8151f3dbff6..b8bf8a7ada7 100644 --- a/src/plugins/qmlprofiler/flamegraphmodel.cpp +++ b/src/plugins/qmlprofiler/flamegraphmodel.cpp @@ -119,14 +119,14 @@ void FlameGraphModel::loadData(qint64 rangeStart, qint64 rangeEnd) continue; if (checkRanges) { - if ((event->startTime() + event->duration() < rangeStart) - || (event->startTime() > rangeEnd)) + if ((event->timestamp() + event->duration() < rangeStart) + || (event->timestamp() > rangeEnd)) continue; } const QmlEvent *potentialParent = callStack.top(); while (potentialParent && - potentialParent->startTime() + potentialParent->duration() <= event->startTime()) { + potentialParent->timestamp() + potentialParent->duration() <= event->timestamp()) { callStack.pop(); stackTop = stackTop->parent; potentialParent = callStack.top(); diff --git a/src/plugins/qmlprofiler/inputeventsmodel.cpp b/src/plugins/qmlprofiler/inputeventsmodel.cpp index cda21cd4459..e7438282169 100644 --- a/src/plugins/qmlprofiler/inputeventsmodel.cpp +++ b/src/plugins/qmlprofiler/inputeventsmodel.cpp @@ -152,7 +152,7 @@ void InputEventsModel::loadData() if (!accepted(type)) continue; - m_data.insert(insert(event.startTime(), 0, type.detailType), + m_data.insert(insert(event.timestamp(), 0, type.detailType), InputEvent(static_cast(event.numericData(0)), event.numericData(1), event.numericData(2))); diff --git a/src/plugins/qmlprofiler/memoryusagemodel.cpp b/src/plugins/qmlprofiler/memoryusagemodel.cpp index 1b988c96b57..013a4ff6890 100644 --- a/src/plugins/qmlprofiler/memoryusagemodel.cpp +++ b/src/plugins/qmlprofiler/memoryusagemodel.cpp @@ -162,12 +162,12 @@ void MemoryUsageModel::loadData() const QVector &types = simpleModel->eventTypes(); foreach (const QmlEvent &event, simpleModel->events()) { const QmlEventType &type = types[event.typeIndex()]; - while (!rangeStack.empty() && rangeStack.top().endTime < event.startTime()) + while (!rangeStack.empty() && rangeStack.top().endTime < event.timestamp()) rangeStack.pop(); if (!accepted(type)) { if (type.rangeType != MaximumRangeType) { - rangeStack.push(RangeStackFrame(event.typeIndex(), event.startTime(), - event.startTime() + event.duration())); + rangeStack.push(RangeStackFrame(event.typeIndex(), event.timestamp(), + event.timestamp() + event.duration())); } continue; } @@ -187,9 +187,9 @@ void MemoryUsageModel::loadData() if (currentUsageIndex != -1) { insertEnd(currentUsageIndex, - event.startTime() - startTime(currentUsageIndex) - 1); + event.timestamp() - startTime(currentUsageIndex) - 1); } - currentUsageIndex = insertStart(event.startTime(), SmallItem); + currentUsageIndex = insertStart(event.timestamp(), SmallItem); m_data.insert(currentUsageIndex, allocation); } } @@ -212,8 +212,8 @@ void MemoryUsageModel::loadData() m_maxSize = currentSize; if (currentJSHeapIndex != -1) insertEnd(currentJSHeapIndex, - event.startTime() - startTime(currentJSHeapIndex) - 1); - currentJSHeapIndex = insertStart(event.startTime(), type.detailType); + event.timestamp() - startTime(currentJSHeapIndex) - 1); + currentJSHeapIndex = insertStart(event.timestamp(), type.detailType); m_data.insert(currentJSHeapIndex, allocation); } } diff --git a/src/plugins/qmlprofiler/pixmapcachemodel.cpp b/src/plugins/qmlprofiler/pixmapcachemodel.cpp index 35aad750e52..3adace69c70 100644 --- a/src/plugins/qmlprofiler/pixmapcachemodel.cpp +++ b/src/plugins/qmlprofiler/pixmapcachemodel.cpp @@ -182,7 +182,7 @@ void PixmapCacheModel::loadData() PixmapCacheItem newEvent; newEvent.pixmapEventType = static_cast(type.detailType); - qint64 pixmapStartTime = event.startTime(); + qint64 pixmapStartTime = event.timestamp(); newEvent.urlIndex = -1; for (QVector::const_iterator it(m_pixmaps.cend()); it != m_pixmaps.cbegin();) { @@ -232,7 +232,7 @@ void PixmapCacheModel::loadData() break; } case PixmapCacheCountChanged: {// Cache Size Changed Event - pixmapStartTime = event.startTime() + 1; // delay 1 ns for proper sorting + pixmapStartTime = event.timestamp() + 1; // delay 1 ns for proper sorting bool uncache = cumulatedCount > event.numericData(2); cumulatedCount = event.numericData(2); @@ -348,7 +348,7 @@ void PixmapCacheModel::loadData() } PixmapState &state = pixmap.sizes[newEvent.sizeIndex]; - // If the pixmap loading wasn't started, start it at traceStartTime() + // If the pixmap loading wasn't started, start it at tracetimestamp() if (state.loadState == Initial) { newEvent.pixmapEventType = PixmapLoadingStarted; newEvent.typeId = event.typeIndex(); diff --git a/src/plugins/qmlprofiler/qmlevent.h b/src/plugins/qmlprofiler/qmlevent.h index 830510c78df..6d81c2b70fc 100644 --- a/src/plugins/qmlprofiler/qmlevent.h +++ b/src/plugins/qmlprofiler/qmlevent.h @@ -29,10 +29,10 @@ namespace QmlProfiler { struct QmlEvent { - QmlEvent(qint64 startTime = -1, qint64 duration = -1, int typeIndex = -1, + QmlEvent(qint64 timestamp = -1, qint64 duration = -1, int typeIndex = -1, qint64 num0 = 0, qint64 num1 = 0, qint64 num2 = 0, qint64 num3 = 0, qint64 num4 = 0) : - m_startTime(startTime), m_duration(duration), m_dataType(NumericData), + m_timestamp(timestamp), m_duration(duration), m_dataType(NumericData), m_typeIndex(typeIndex) { m_numericData[0] = num0; @@ -42,14 +42,14 @@ struct QmlEvent { m_numericData[4] = num4; } - QmlEvent(qint64 startTime, qint64 duration, int typeIndex, const QString &data) - : m_startTime(startTime), m_duration(duration), m_typeIndex(typeIndex) + QmlEvent(qint64 timestamp, qint64 duration, int typeIndex, const QString &data) + : m_timestamp(timestamp), m_duration(duration), m_typeIndex(typeIndex) { assignStringData(data); } QmlEvent(const QmlEvent &other) : - m_startTime(other.m_startTime), m_duration(other.m_duration), + m_timestamp(other.m_timestamp), m_duration(other.m_duration), m_dataType(other.m_dataType), m_typeIndex(other.m_typeIndex) { assignData(other); @@ -61,7 +61,7 @@ struct QmlEvent { if (m_dataType == StringData) delete m_stringData; - m_startTime = other.m_startTime; + m_timestamp = other.m_timestamp; m_duration = other.m_duration; m_typeIndex = other.m_typeIndex; m_dataType = other.m_dataType; @@ -76,8 +76,8 @@ struct QmlEvent { delete m_stringData; } - qint64 startTime() const { return m_startTime; } - void setStartTime(qint64 startTime) { m_startTime = startTime; } + qint64 timestamp() const { return m_timestamp; } + void setTimestamp(qint64 timestamp) { m_timestamp = timestamp; } qint64 duration() const { return m_duration; } void setDuration(qint64 duration) { m_duration = duration; } @@ -114,7 +114,7 @@ struct QmlEvent { bool isValid() const { - return m_startTime != -1; + return m_timestamp != -1; } private: @@ -122,7 +122,7 @@ private: static const quint8 StringData = 254; static const quint8 NumericData = 255; - qint64 m_startTime; + qint64 m_timestamp; qint64 m_duration; union { qint64 m_numericData[5]; diff --git a/src/plugins/qmlprofiler/qmlprofileranimationsmodel.cpp b/src/plugins/qmlprofiler/qmlprofileranimationsmodel.cpp index a0217af9a94..36b956a1458 100644 --- a/src/plugins/qmlprofiler/qmlprofileranimationsmodel.cpp +++ b/src/plugins/qmlprofiler/qmlprofileranimationsmodel.cpp @@ -84,10 +84,10 @@ void QmlProfilerAnimationsModel::loadData() qint64 estimatedDuration = event.numericData(0) > 0 ? 1e9/event.numericData(0) : 1; // the profiler registers the animation events at the end of them - qint64 realEndTime = event.startTime(); + qint64 realEndTime = event.timestamp(); // ranges should not overlap. If they do, our estimate wasn't accurate enough - qint64 realStartTime = qMax(event.startTime() - estimatedDuration, + qint64 realStartTime = qMax(event.timestamp() - estimatedDuration, minNextStartTimes[lastThread]); // Sometimes our estimate is far off or the server has miscalculated the frame rate @@ -109,7 +109,7 @@ void QmlProfilerAnimationsModel::loadData() m_maxRenderThreadAnimations = qMax(lastEvent.animationcount, m_maxRenderThreadAnimations); - minNextStartTimes[lastThread] = event.startTime() + 1; + minNextStartTimes[lastThread] = event.timestamp() + 1; updateProgress(count(), referenceList.count()); } diff --git a/src/plugins/qmlprofiler/qmlprofilerdatamodel.cpp b/src/plugins/qmlprofiler/qmlprofilerdatamodel.cpp index 6ac21947396..19852475c7b 100644 --- a/src/plugins/qmlprofiler/qmlprofilerdatamodel.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerdatamodel.cpp @@ -174,7 +174,7 @@ bool QmlProfilerDataModel::isEmpty() const inline static bool operator<(const QmlEvent &t1, const QmlEvent &t2) { - return t1.startTime() < t2.startTime(); + return t1.timestamp() < t2.timestamp(); } inline static uint qHash(const QmlEventType &type) @@ -271,7 +271,7 @@ qint64 QmlProfilerDataModel::lastTimeMark() const if (d->eventList.isEmpty()) return 0; - return d->eventList.last().startTime() + d->eventList.last().duration(); + return d->eventList.last().timestamp() + d->eventList.last().duration(); } void QmlProfilerDataModel::detailsChanged(int requestId, const QString &newString) diff --git a/src/plugins/qmlprofiler/qmlprofilerrangemodel.cpp b/src/plugins/qmlprofiler/qmlprofilerrangemodel.cpp index a34085a2dd9..2dc7b363b24 100644 --- a/src/plugins/qmlprofiler/qmlprofilerrangemodel.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerrangemodel.cpp @@ -77,7 +77,7 @@ void QmlProfilerRangeModel::loadData() continue; // store starttime-based instance - m_data.insert(insert(event.startTime(), event.duration(), event.typeIndex()), + m_data.insert(insert(event.timestamp(), event.duration(), event.typeIndex()), QmlRangeEventStartInstance()); updateProgress(count(), eventList.count() * 5); } diff --git a/src/plugins/qmlprofiler/qmlprofilerstatisticsmodel.cpp b/src/plugins/qmlprofiler/qmlprofilerstatisticsmodel.cpp index f64d95258bc..c46b51d1528 100644 --- a/src/plugins/qmlprofiler/qmlprofilerstatisticsmodel.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerstatisticsmodel.cpp @@ -188,8 +188,8 @@ void QmlProfilerStatisticsModel::loadData(qint64 rangeStart, qint64 rangeEnd) continue; if (checkRanges) { - if ((event->startTime() + event->duration() < rangeStart) - || (event->startTime() > rangeEnd)) + if ((event->timestamp() + event->duration() < rangeStart) + || (event->timestamp() > rangeEnd)) continue; } @@ -208,17 +208,17 @@ void QmlProfilerStatisticsModel::loadData(qint64 rangeStart, qint64 rangeEnd) durations[event->typeIndex()].append(event->duration()); // qml time computation - if (event->startTime() > lastEndTime) { // assume parent event if starts before last end + if (event->timestamp() > lastEndTime) { // assume parent event if starts before last end qmlTime += event->duration(); - lastEndTime = event->startTime() + event->duration(); + lastEndTime = event->timestamp() + event->duration(); } // // binding loop detection // const QmlEvent *potentialParent = callStack.top(); - while (potentialParent && !(potentialParent->startTime() + potentialParent->duration() > - event->startTime())) { + while (potentialParent && !(potentialParent->timestamp() + potentialParent->duration() > + event->timestamp())) { callStack.pop(); potentialParent = callStack.top(); } @@ -362,14 +362,14 @@ void QmlProfilerStatisticsParentsModel::loadData() continue; // level computation - if (endtimesPerLevel[level] > event.startTime()) { + if (endtimesPerLevel[level] > event.timestamp()) { level++; } else { while (level > Constants::QML_MIN_LEVEL && - endtimesPerLevel[level-1] <= event.startTime()) + endtimesPerLevel[level-1] <= event.timestamp()) level--; } - endtimesPerLevel[level] = event.startTime() + event.duration(); + endtimesPerLevel[level] = event.timestamp() + event.duration(); int parentTypeIndex = -1; if (level > Constants::QML_MIN_LEVEL && lastParent.contains(level-1)) @@ -424,14 +424,14 @@ void QmlProfilerStatisticsChildrenModel::loadData() continue; // level computation - if (endtimesPerLevel[level] > event.startTime()) { + if (endtimesPerLevel[level] > event.timestamp()) { level++; } else { while (level > Constants::QML_MIN_LEVEL && - endtimesPerLevel[level-1] <= event.startTime()) + endtimesPerLevel[level-1] <= event.timestamp()) level--; } - endtimesPerLevel[level] = event.startTime() + event.duration(); + endtimesPerLevel[level] = event.timestamp() + event.duration(); int parentId = -1; diff --git a/src/plugins/qmlprofiler/qmlprofilertracefile.cpp b/src/plugins/qmlprofiler/qmlprofilertracefile.cpp index 7a49f6175e7..5e93f0b04a8 100644 --- a/src/plugins/qmlprofiler/qmlprofilertracefile.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertracefile.cpp @@ -369,7 +369,7 @@ void QmlProfilerFileReader::loadEvents(QXmlStreamReader &stream) continue; } - event.setStartTime(attributes.value(_("startTime")).toLongLong()); + event.setTimestamp(attributes.value(_("startTime")).toLongLong()); if (attributes.hasAttribute(_("duration"))) event.setDuration(attributes.value(_("duration")).toLongLong()); @@ -591,14 +591,13 @@ void QmlProfilerFileWriter::save(QIODevice *device) const QmlEvent &event = m_events[rangeIndex]; stream.writeStartElement(_("range")); - stream.writeAttribute(_("startTime"), QString::number(event.startTime())); + stream.writeAttribute(_("startTime"), QString::number(event.timestamp())); if (event.duration() > 0) // no need to store duration of instantaneous events stream.writeAttribute(_("duration"), QString::number(event.duration())); stream.writeAttribute(_("eventIndex"), QString::number(event.typeIndex())); const QmlEventType &type = m_eventTypes[event.typeIndex()]; - if (type.message == Event) { if (type.detailType == AnimationFrame) { // special: animation event diff --git a/src/plugins/qmlprofiler/scenegraphtimelinemodel.cpp b/src/plugins/qmlprofiler/scenegraphtimelinemodel.cpp index cf0723b3296..ba3b7410aca 100644 --- a/src/plugins/qmlprofiler/scenegraphtimelinemodel.cpp +++ b/src/plugins/qmlprofiler/scenegraphtimelinemodel.cpp @@ -150,7 +150,7 @@ void SceneGraphTimelineModel::loadData() // look incomplete if that was left out as the printf profiler lists it, too, and people // are apparently comparing that. Unfortunately it is somewhat redundant as the other // parts of the breakdown are usually very short. - qint64 startTime = event.startTime() - event.numericData(0) - event.numericData(1) - + qint64 startTime = event.timestamp() - event.numericData(0) - event.numericData(1) - event.numericData(2) - event.numericData(3); startTime += insert(startTime, event.numericData(0), event.typeIndex(), RenderPreprocess); startTime += insert(startTime, event.numericData(1), event.typeIndex(), RenderUpdate); @@ -159,19 +159,19 @@ void SceneGraphTimelineModel::loadData() break; } case SceneGraphAdaptationLayerFrame: { - qint64 startTime = event.startTime() - event.numericData(1) - event.numericData(2); + qint64 startTime = event.timestamp() - event.numericData(1) - event.numericData(2); startTime += insert(startTime, event.numericData(1), event.typeIndex(), GlyphRender, event.numericData(0)); insert(startTime, event.numericData(2), event.typeIndex(), GlyphStore, event.numericData(0)); break; } case SceneGraphContextFrame: { - insert(event.startTime() - event.numericData(0), event.numericData(0), event.typeIndex(), + insert(event.timestamp() - event.numericData(0), event.numericData(0), event.typeIndex(), Material); break; } case SceneGraphRenderLoopFrame: { - qint64 startTime = event.startTime() - event.numericData(0) - event.numericData(1) - + qint64 startTime = event.timestamp() - event.numericData(0) - event.numericData(1) - event.numericData(2); startTime += insert(startTime, event.numericData(0), event.typeIndex(), RenderThreadSync); @@ -181,7 +181,7 @@ void SceneGraphTimelineModel::loadData() break; } case SceneGraphTexturePrepare: { - qint64 startTime = event.startTime() - event.numericData(0) - event.numericData(1) - + qint64 startTime = event.timestamp() - event.numericData(0) - event.numericData(1) - event.numericData(2) - event.numericData(3) - event.numericData(4); startTime += insert(startTime, event.numericData(0), event.typeIndex(), TextureBind); startTime += insert(startTime, event.numericData(1), event.typeIndex(), TextureConvert); @@ -191,12 +191,12 @@ void SceneGraphTimelineModel::loadData() break; } case SceneGraphTextureDeletion: { - insert(event.startTime() - event.numericData(0), event.numericData(0), event.typeIndex(), + insert(event.timestamp() - event.numericData(0), event.numericData(0), event.typeIndex(), TextureDeletion); break; } case SceneGraphPolishAndSync: { - qint64 startTime = event.startTime() - event.numericData(0) - event.numericData(1) - + qint64 startTime = event.timestamp() - event.numericData(0) - event.numericData(1) - event.numericData(2) - event.numericData(3); startTime += insert(startTime, event.numericData(0), event.typeIndex(), Polish); @@ -207,13 +207,13 @@ void SceneGraphTimelineModel::loadData() } case SceneGraphWindowsAnimations: { // GUI thread, separate animations stage - insert(event.startTime() - event.numericData(0), event.numericData(0), event.typeIndex(), + insert(event.timestamp() - event.numericData(0), event.numericData(0), event.typeIndex(), Animations); break; } case SceneGraphPolishFrame: { // GUI thread, separate polish stage - insert(event.startTime() - event.numericData(0), event.numericData(0), event.typeIndex(), + insert(event.timestamp() - event.numericData(0), event.numericData(0), event.typeIndex(), Polish); break; }