QmlProfiler: Load the timeline model data event by event

All the models do the same thing when loading the data: They iterate
the list of events, determine for each one if they accept it, and if
so, they load it. After the list has been fully loaded, they do some
finalization. This can be centralized, and ultimately we won't need to
expose the central QVector<QmlEvent> for that anymore.

Change-Id: Ia82facfdc3968200bbec323a02f2fcc02ac44e9e
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
Ulf Hermann
2016-04-26 13:23:35 +02:00
parent 67378a7928
commit 5ba6f04d4b
16 changed files with 460 additions and 496 deletions

View File

@@ -28,11 +28,6 @@
namespace QmlProfiler {
namespace Internal {
bool DebugMessagesModel::accepted(const QmlEventType &event) const
{
return event.message == DebugMessage;
}
DebugMessagesModel::DebugMessagesModel(QmlProfilerModelManager *manager, QObject *parent) :
QmlProfilerTimelineModel(manager, DebugMessage, MaximumRangeType, ProfileDebugMessages, parent),
m_maximumMsgType(-1)
@@ -99,24 +94,16 @@ int DebugMessagesModel::collapsedRow(int index) const
return 1;
}
void DebugMessagesModel::loadData()
void DebugMessagesModel::loadEvent(const QmlEvent &event, const QmlEventType &type)
{
QmlProfilerDataModel *simpleModel = modelManager()->qmlModel();
if (simpleModel->isEmpty())
return;
const QVector<QmlEventType> &types = simpleModel->eventTypes();
foreach (const QmlEvent &event, simpleModel->events()) {
const QmlEventType &type = types[event.typeIndex()];
if (!accepted(type) || event.timestamp() < 0)
continue;
m_data.insert(insert(event.timestamp(), 0, type.detailType),
MessageData(event.string(), event.typeIndex()));
if (type.detailType > m_maximumMsgType)
m_maximumMsgType = event.typeIndex();
}
}
void DebugMessagesModel::finalize()
{
setCollapsedRowCount(2);
setExpandedRowCount(m_maximumMsgType + 2);
}

View File

@@ -34,9 +34,6 @@ class DebugMessagesModel : public QmlProfilerTimelineModel
{
Q_OBJECT
protected:
bool accepted(const QmlEventType &event) const override;
public:
DebugMessagesModel(QmlProfilerModelManager *manager, QObject *parent = 0);
@@ -46,7 +43,8 @@ public:
QVariantMap details(int index) const override;
int expandedRow(int index) const override;
int collapsedRow(int index) const override;
void loadData() override;
void loadEvent(const QmlEvent &event, const QmlEventType &type) override;
void finalize() override;
void clear() override;
QVariantMap location(int index) const override;

View File

@@ -140,18 +140,8 @@ int InputEventsModel::collapsedRow(int index) const
return 1;
}
void InputEventsModel::loadData()
void InputEventsModel::loadEvent(const QmlEvent &event, const QmlEventType &type)
{
QmlProfilerDataModel *simpleModel = modelManager()->qmlModel();
if (simpleModel->isEmpty())
return;
const QVector<QmlEventType> &types = simpleModel->eventTypes();
foreach (const QmlEvent &event, simpleModel->events()) {
const QmlEventType &type = types[event.typeIndex()];
if (!accepted(type))
continue;
m_data.insert(insert(event.timestamp(), 0, type.detailType),
InputEvent(static_cast<InputEventType>(event.number<qint32>(0)),
event.number<qint32>(1), event.number<qint32>(2)));
@@ -162,7 +152,10 @@ void InputEventsModel::loadData()
} else if (m_keyTypeId == -1) {
m_keyTypeId = event.typeIndex();
}
}
}
void InputEventsModel::finalize()
{
setCollapsedRowCount(2);
setExpandedRowCount(3);
}

View File

@@ -36,6 +36,9 @@ class InputEventsModel : public QmlProfilerTimelineModel
protected:
bool accepted(const QmlEventType &event) const;
void loadEvent(const QmlEvent &event, const QmlEventType &type) override;
void finalize() override;
void clear() override;
public:
struct InputEvent {
@@ -53,8 +56,6 @@ public:
QVariantMap details(int index) const;
int expandedRow(int index) const;
int collapsedRow(int index) const;
void loadData();
void clear();
private:
static QMetaEnum metaEnum(const char *name);

View File

@@ -27,15 +27,12 @@
#include "qmlprofilermodelmanager.h"
#include "qmlprofilereventtypes.h"
#include <QStack>
namespace QmlProfiler {
namespace Internal {
MemoryUsageModel::MemoryUsageModel(QmlProfilerModelManager *manager, QObject *parent) :
QmlProfilerTimelineModel(manager, MemoryAllocation, MaximumRangeType, ProfileMemory, parent)
{
m_maxSize = 1;
announceFeatures((1ULL << mainFeature()) | Constants::QML_JS_RANGE_FEATURES);
}
@@ -137,94 +134,78 @@ QVariantMap MemoryUsageModel::details(int index) const
return result;
}
struct RangeStackFrame {
RangeStackFrame() : originTypeIndex(-1), startTime(-1), endTime(-1) {}
RangeStackFrame(int originTypeIndex, qint64 startTime, qint64 endTime) :
originTypeIndex(originTypeIndex), startTime(startTime), endTime(endTime) {}
int originTypeIndex;
qint64 startTime;
qint64 endTime;
};
void MemoryUsageModel::loadData()
bool MemoryUsageModel::accepted(const QmlEventType &type) const
{
QmlProfilerDataModel *simpleModel = modelManager()->qmlModel();
if (simpleModel->isEmpty())
return;
return QmlProfilerTimelineModel::accepted(type) || type.rangeType != MaximumRangeType;
}
qint64 currentSize = 0;
qint64 currentUsage = 0;
int currentUsageIndex = -1;
int currentJSHeapIndex = -1;
QStack<RangeStackFrame> rangeStack;
const QVector<QmlEventType> &types = simpleModel->eventTypes();
foreach (const QmlEvent &event, simpleModel->events()) {
const QmlEventType &type = types[event.typeIndex()];
while (!rangeStack.empty() && rangeStack.top().endTime < event.timestamp())
rangeStack.pop();
if (!accepted(type)) {
void MemoryUsageModel::loadEvent(const QmlEvent &event, const QmlEventType &type)
{
while (!m_rangeStack.empty() && m_rangeStack.top().endTime < event.timestamp())
m_rangeStack.pop();
if (type.message != MemoryAllocation) {
if (type.rangeType != MaximumRangeType) {
rangeStack.push(RangeStackFrame(event.typeIndex(), event.timestamp(),
m_rangeStack.push(RangeStackFrame(event.typeIndex(), event.timestamp(),
event.timestamp() + event.duration()));
}
continue;
return;
}
if (type.detailType == SmallItem || type.detailType == LargeItem) {
if (!rangeStack.empty() && currentUsageIndex > -1 &&
type.detailType == selectionId(currentUsageIndex) &&
m_data[currentUsageIndex].originTypeIndex == rangeStack.top().originTypeIndex &&
rangeStack.top().startTime < startTime(currentUsageIndex)) {
m_data[currentUsageIndex].update(event.number<qint64>(0));
currentUsage = m_data[currentUsageIndex].size;
if (!m_rangeStack.empty() && m_currentUsageIndex > -1 &&
type.detailType == selectionId(m_currentUsageIndex) &&
m_data[m_currentUsageIndex].originTypeIndex == m_rangeStack.top().originTypeIndex &&
m_rangeStack.top().startTime < startTime(m_currentUsageIndex)) {
m_data[m_currentUsageIndex].update(event.number<qint64>(0));
m_currentUsage = m_data[m_currentUsageIndex].size;
} else {
MemoryAllocationItem allocation(event.typeIndex(), currentUsage,
rangeStack.empty() ? -1 : rangeStack.top().originTypeIndex);
MemoryAllocationItem allocation(event.typeIndex(), m_currentUsage,
m_rangeStack.empty() ? -1 : m_rangeStack.top().originTypeIndex);
allocation.update(event.number<qint64>(0));
currentUsage = allocation.size;
m_currentUsage = allocation.size;
if (currentUsageIndex != -1) {
insertEnd(currentUsageIndex,
event.timestamp() - startTime(currentUsageIndex) - 1);
if (m_currentUsageIndex != -1) {
insertEnd(m_currentUsageIndex,
event.timestamp() - startTime(m_currentUsageIndex) - 1);
}
currentUsageIndex = insertStart(event.timestamp(), SmallItem);
m_data.insert(currentUsageIndex, allocation);
m_currentUsageIndex = insertStart(event.timestamp(), SmallItem);
m_data.insert(m_currentUsageIndex, allocation);
}
}
if (type.detailType == HeapPage || type.detailType == LargeItem) {
if (!rangeStack.empty() && currentJSHeapIndex > -1 &&
type.detailType == selectionId(currentJSHeapIndex) &&
m_data[currentJSHeapIndex].originTypeIndex ==
rangeStack.top().originTypeIndex &&
rangeStack.top().startTime < startTime(currentJSHeapIndex)) {
m_data[currentJSHeapIndex].update(event.number<qint64>(0));
currentSize = m_data[currentJSHeapIndex].size;
if (!m_rangeStack.empty() && m_currentJSHeapIndex > -1 &&
type.detailType == selectionId(m_currentJSHeapIndex) &&
m_data[m_currentJSHeapIndex].originTypeIndex ==
m_rangeStack.top().originTypeIndex &&
m_rangeStack.top().startTime < startTime(m_currentJSHeapIndex)) {
m_data[m_currentJSHeapIndex].update(event.number<qint64>(0));
m_currentSize = m_data[m_currentJSHeapIndex].size;
} else {
MemoryAllocationItem allocation(event.typeIndex(), currentSize,
rangeStack.empty() ? -1 : rangeStack.top().originTypeIndex);
MemoryAllocationItem allocation(event.typeIndex(), m_currentSize,
m_rangeStack.empty() ? -1 : m_rangeStack.top().originTypeIndex);
allocation.update(event.number<qint64>(0));
currentSize = allocation.size;
m_currentSize = allocation.size;
if (currentSize > m_maxSize)
m_maxSize = currentSize;
if (currentJSHeapIndex != -1)
insertEnd(currentJSHeapIndex,
event.timestamp() - startTime(currentJSHeapIndex) - 1);
currentJSHeapIndex = insertStart(event.timestamp(), type.detailType);
m_data.insert(currentJSHeapIndex, allocation);
}
if (m_currentSize > m_maxSize)
m_maxSize = m_currentSize;
if (m_currentJSHeapIndex != -1)
insertEnd(m_currentJSHeapIndex,
event.timestamp() - startTime(m_currentJSHeapIndex) - 1);
m_currentJSHeapIndex = insertStart(event.timestamp(), type.detailType);
m_data.insert(m_currentJSHeapIndex, allocation);
}
}
}
if (currentJSHeapIndex != -1)
insertEnd(currentJSHeapIndex, modelManager()->traceTime()->endTime() -
startTime(currentJSHeapIndex) - 1);
if (currentUsageIndex != -1)
insertEnd(currentUsageIndex, modelManager()->traceTime()->endTime() -
startTime(currentUsageIndex) - 1);
void MemoryUsageModel::finalize()
{
if (m_currentJSHeapIndex != -1)
insertEnd(m_currentJSHeapIndex, modelManager()->traceTime()->endTime() -
startTime(m_currentJSHeapIndex) - 1);
if (m_currentUsageIndex != -1)
insertEnd(m_currentUsageIndex, modelManager()->traceTime()->endTime() -
startTime(m_currentUsageIndex) - 1);
computeNesting();
@@ -236,6 +217,11 @@ void MemoryUsageModel::clear()
{
m_data.clear();
m_maxSize = 1;
m_currentSize = 0;
m_currentUsage = 0;
m_currentUsageIndex = -1;
m_currentJSHeapIndex = -1;
m_rangeStack.clear();
QmlProfilerTimelineModel::clear();
}

View File

@@ -30,6 +30,7 @@
#include <QStringList>
#include <QColor>
#include <QStack>
namespace QmlProfiler {
namespace Internal {
@@ -68,14 +69,30 @@ public:
QVariantMap details(int index) const;
protected:
void loadData();
void clear();
bool accepted(const QmlEventType &type) const override;
void loadEvent(const QmlEvent &event, const QmlEventType &type) override;
void finalize() override;
void clear() override;
private:
struct RangeStackFrame {
RangeStackFrame() : originTypeIndex(-1), startTime(-1), endTime(-1) {}
RangeStackFrame(int originTypeIndex, qint64 startTime, qint64 endTime) :
originTypeIndex(originTypeIndex), startTime(startTime), endTime(endTime) {}
int originTypeIndex;
qint64 startTime;
qint64 endTime;
};
static QString memoryTypeName(int type);
QVector<MemoryAllocationItem> m_data;
qint64 m_maxSize;
QStack<RangeStackFrame> m_rangeStack;
qint64 m_maxSize = 1;
qint64 m_currentSize = 0;
qint64 m_currentUsage = 0;
int m_currentUsageIndex = -1;
int m_currentJSHeapIndex = -1;
};
} // namespace Internal

View File

@@ -34,7 +34,6 @@ PixmapCacheModel::PixmapCacheModel(QmlProfilerModelManager *manager, QObject *pa
QmlProfilerTimelineModel(manager, PixmapCacheEvent, MaximumRangeType, ProfilePixmapCache,
parent)
{
m_maxCacheSize = 1;
}
int PixmapCacheModel::rowMaxValue(int rowNumber) const
@@ -164,22 +163,8 @@ QVariantMap PixmapCacheModel::details(int index) const
* necessarily the order the pixmaps are really loaded but it's the best we can do with the given
* information. If they're loaded sequentially the representation is correct.
*/
void PixmapCacheModel::loadData()
void PixmapCacheModel::loadEvent(const QmlEvent &event, const QmlEventType &type)
{
QmlProfilerDataModel *simpleModel = modelManager()->qmlModel();
if (simpleModel->isEmpty())
return;
int lastCacheSizeEvent = -1;
int cumulatedCount = 0;
const QVector<QmlEventType> &types = simpleModel->eventTypes();
foreach (const QmlEvent &event, simpleModel->events()) {
const QmlEventType &type = types[event.typeIndex()];
if (!accepted(type))
continue;
PixmapCacheItem newEvent;
newEvent.pixmapEventType = static_cast<PixmapEventType>(type.detailType);
qint64 pixmapStartTime = event.timestamp();
@@ -224,7 +209,7 @@ void PixmapCacheModel::loadData()
PixmapState &state = pixmap.sizes[newEvent.sizeIndex];
if (state.cacheState == ToBeCached) {
lastCacheSizeEvent = updateCacheCount(lastCacheSizeEvent, pixmapStartTime,
m_lastCacheSizeEvent = updateCacheCount(m_lastCacheSizeEvent, pixmapStartTime,
state.size.width() * state.size.height(), newEvent,
event.typeIndex());
state.cacheState = Cached;
@@ -234,8 +219,8 @@ void PixmapCacheModel::loadData()
case PixmapCacheCountChanged: {// Cache Size Changed Event
pixmapStartTime = event.timestamp() + 1; // delay 1 ns for proper sorting
bool uncache = cumulatedCount > event.number<qint32>(2);
cumulatedCount = event.number<qint32>(2);
bool uncache = m_cumulatedCount > event.number<qint32>(2);
m_cumulatedCount = event.number<qint32>(2);
qint64 pixSize = 0;
// First try to find a preferred pixmap, which either is Corrupt and will be uncached
@@ -285,7 +270,7 @@ void PixmapCacheModel::loadData()
pixmap.sizes << PixmapState(uncache ? Uncached : ToBeCached);
}
lastCacheSizeEvent = updateCacheCount(lastCacheSizeEvent, pixmapStartTime, pixSize,
m_lastCacheSizeEvent = updateCacheCount(m_lastCacheSizeEvent, pixmapStartTime, pixSize,
newEvent, event.typeIndex());
break;
}
@@ -348,7 +333,7 @@ void PixmapCacheModel::loadData()
}
PixmapState &state = pixmap.sizes[newEvent.sizeIndex];
// If the pixmap loading wasn't started, start it at tracetimestamp()
// If the pixmap loading wasn't started, start it at traceStartTime()
if (state.loadState == Initial) {
newEvent.pixmapEventType = PixmapLoadingStarted;
newEvent.typeId = event.typeIndex();
@@ -358,8 +343,8 @@ void PixmapCacheModel::loadData()
m_data.insert(state.started, newEvent);
// All other indices are wrong now as we've prepended. Fix them ...
if (lastCacheSizeEvent >= state.started)
++lastCacheSizeEvent;
if (m_lastCacheSizeEvent >= state.started)
++m_lastCacheSizeEvent;
for (int pixmapIndex = 0; pixmapIndex < m_pixmaps.count(); ++pixmapIndex) {
Pixmap &brokenPixmap = m_pixmaps[pixmapIndex];
@@ -397,14 +382,16 @@ void PixmapCacheModel::loadData()
default:
break;
}
}
void PixmapCacheModel::finalize()
{
if (m_lastCacheSizeEvent != -1) {
insertEnd(m_lastCacheSizeEvent, modelManager()->traceTime()->endTime() -
startTime(m_lastCacheSizeEvent));
}
if (lastCacheSizeEvent != -1)
insertEnd(lastCacheSizeEvent, modelManager()->traceTime()->endTime() -
startTime(lastCacheSizeEvent));
resizeUnfinishedLoads();
computeMaxCacheSize();
flattenLoads();
computeNesting();
@@ -413,14 +400,15 @@ void PixmapCacheModel::loadData()
void PixmapCacheModel::clear()
{
m_pixmaps.clear();
m_maxCacheSize = 1;
m_data.clear();
m_maxCacheSize = 1;
m_lastCacheSizeEvent = -1;
m_cumulatedCount = 0;
QmlProfilerTimelineModel::clear();
}
void PixmapCacheModel::computeMaxCacheSize()
{
m_maxCacheSize = 1;
foreach (const PixmapCacheModel::PixmapCacheItem &event, m_data) {
if (event.pixmapEventType == PixmapCacheModel::PixmapCacheCountChanged) {
if (event.cacheSize > m_maxCacheSize)

View File

@@ -106,19 +106,23 @@ public:
QVariantMap details(int index) const;
protected:
void loadData();
void clear();
void loadEvent(const QmlEvent &event, const QmlEventType &type) override;
void finalize() override;
void clear() override;
private:
void computeMaxCacheSize();
void resizeUnfinishedLoads();
void flattenLoads();
int updateCacheCount(int lastCacheSizeEvent, qint64 startTime, qint64 pixSize,
int updateCacheCount(int m_lastCacheSizeEvent, qint64 startTime, qint64 pixSize,
PixmapCacheItem &newEvent, int typeId);
QVector<PixmapCacheItem> m_data;
QVector<Pixmap> m_pixmaps;
qint64 m_maxCacheSize;
qint64 m_maxCacheSize = 1;
int m_lastCacheSizeEvent = -1;
int m_cumulatedCount = 0;
static const int s_pixmapCacheCountHue = 240;
};

View File

@@ -44,11 +44,11 @@ QmlProfilerAnimationsModel::QmlProfilerAnimationsModel(QmlProfilerModelManager *
QObject *parent) :
QmlProfilerTimelineModel(manager, Event, MaximumRangeType, ProfileAnimations, parent)
{
m_maxGuiThreadAnimations = m_maxRenderThreadAnimations = 0;
}
void QmlProfilerAnimationsModel::clear()
{
m_minNextStartTimes[0] = m_minNextStartTimes[1] = 0;
m_maxGuiThreadAnimations = m_maxRenderThreadAnimations = 0;
m_data.clear();
QmlProfilerTimelineModel::clear();
@@ -59,26 +59,10 @@ bool QmlProfilerAnimationsModel::accepted(const QmlEventType &event) const
return QmlProfilerTimelineModel::accepted(event) && event.detailType == AnimationFrame;
}
void QmlProfilerAnimationsModel::loadData()
void QmlProfilerAnimationsModel::loadEvent(const QmlEvent &event, const QmlEventType &type)
{
QmlProfilerDataModel *simpleModel = modelManager()->qmlModel();
if (simpleModel->isEmpty())
return;
// collect events
const QVector<QmlEvent> &referenceList = simpleModel->events();
const QVector<QmlEventType> &typeList = simpleModel->eventTypes();
AnimationThread lastThread;
QmlPaintEventData lastEvent;
qint64 minNextStartTimes[] = {0, 0};
foreach (const QmlEvent &event, referenceList) {
const QmlEventType &type = typeList[event.typeIndex()];
if (!accepted(type))
continue;
lastThread = (AnimationThread)event.number<qint32>(2);
Q_UNUSED(type);
AnimationThread lastThread = (AnimationThread)event.number<qint32>(2);
// initial estimation of the event duration: 1/framerate
qint64 estimatedDuration = event.number<qint32>(0) > 0 ? 1e9 / event.number<qint32>(0) : 1;
@@ -88,7 +72,7 @@ void QmlProfilerAnimationsModel::loadData()
// ranges should not overlap. If they do, our estimate wasn't accurate enough
qint64 realStartTime = qMax(event.timestamp() - estimatedDuration,
minNextStartTimes[lastThread]);
m_minNextStartTimes[lastThread]);
// Sometimes our estimate is far off or the server has miscalculated the frame rate
if (realStartTime >= realEndTime)
@@ -96,10 +80,11 @@ void QmlProfilerAnimationsModel::loadData()
// Don't "fix" the framerate even if we've fixed the duration.
// The server should know better after all and if it doesn't we want to see that.
QmlPaintEventData lastEvent;
lastEvent.typeId = event.typeIndex();
lastEvent.framerate = event.number<qint32>(0);
lastEvent.animationcount = event.number<qint32>(1);
QTC_ASSERT(lastEvent.animationcount > 0, continue);
QTC_ASSERT(lastEvent.animationcount > 0, return);
m_data.insert(insert(realStartTime, realEndTime - realStartTime, lastThread), lastEvent);
@@ -109,9 +94,11 @@ void QmlProfilerAnimationsModel::loadData()
m_maxRenderThreadAnimations = qMax(lastEvent.animationcount,
m_maxRenderThreadAnimations);
minNextStartTimes[lastThread] = event.timestamp() + 1;
}
m_minNextStartTimes[lastThread] = event.timestamp() + 1;
}
void QmlProfilerAnimationsModel::finalize()
{
computeNesting();
setExpandedRowCount((m_maxGuiThreadAnimations == 0 || m_maxRenderThreadAnimations == 0) ? 2 : 3);
setCollapsedRowCount(expandedRowCount());

View File

@@ -64,16 +64,18 @@ public:
QVariantList labels() const;
QVariantMap details(int index) const;
bool accepted(const QmlEventType &event) const;
protected:
void loadData();
void clear();
bool accepted(const QmlEventType &event) const override;
void loadEvent(const QmlEvent &event, const QmlEventType &type) override;
void finalize() override;
void clear() override;
private:
QVector<QmlProfilerAnimationsModel::QmlPaintEventData> m_data;
int m_maxGuiThreadAnimations;
int m_maxRenderThreadAnimations;
int m_maxGuiThreadAnimations = 0;
int m_maxRenderThreadAnimations = 0;
qint64 m_minNextStartTimes[2] = {0, 0};
int rowFromThreadId(int threadId) const;
};

View File

@@ -62,25 +62,16 @@ bool QmlProfilerRangeModel::supportsBindingLoops() const
return rangeType() == Binding || rangeType() == HandlingSignal;
}
void QmlProfilerRangeModel::loadData()
void QmlProfilerRangeModel::loadEvent(const QmlEvent &event, const QmlEventType &type)
{
QmlProfilerDataModel *simpleModel = modelManager()->qmlModel();
if (simpleModel->isEmpty())
return;
// collect events
const QVector<QmlEvent> &eventList = simpleModel->events();
const QVector<QmlEventType> &typesList = simpleModel->eventTypes();
foreach (const QmlEvent &event, eventList) {
const QmlEventType &type = typesList[event.typeIndex()];
if (!accepted(type))
continue;
Q_UNUSED(type);
// store starttime-based instance
m_data.insert(insert(event.timestamp(), event.duration(), event.typeIndex()),
QmlRangeEventStartInstance());
}
}
void QmlProfilerRangeModel::finalize()
{
// compute range nesting
computeNesting();

View File

@@ -73,8 +73,9 @@ public:
virtual QList<const Timeline::TimelineRenderPass *> supportedRenderPasses() const;
protected:
void loadData();
void clear();
void loadEvent(const QmlEvent &event, const QmlEventType &type) override;
void finalize() override;
void clear() override;
private:

View File

@@ -134,4 +134,21 @@ QVariantMap QmlProfilerTimelineModel::locationFromTypeId(int index) const
return result;
}
void QmlProfilerTimelineModel::loadData()
{
QmlProfilerDataModel *simpleModel = modelManager()->qmlModel();
if (simpleModel->isEmpty())
return;
const QVector<QmlEventType> &types = simpleModel->eventTypes();
foreach (const QmlEvent &event, simpleModel->events()) {
const QmlEventType &type = types[event.typeIndex()];
if (accepted(type)) {
loadEvent(event, type);
}
}
finalize();
}
} // namespace QmlProfiler

View File

@@ -53,7 +53,10 @@ public:
Q_INVOKABLE virtual int bindingLoopDest(int index) const;
QVariantMap locationFromTypeId(int index) const;
virtual void loadData() = 0;
void loadData();
virtual void loadEvent(const QmlEvent &event, const QmlEventType &type) = 0;
virtual void finalize() = 0;
void clear();
private slots:
@@ -68,6 +71,8 @@ private:
const RangeType m_rangeType;
const ProfileFeature m_mainFeature;
QmlProfilerModelManager *const m_modelManager;
void updateProgress(qint64 count, qint64 max) const;
};
}
} // namespace QmlProfiler

View File

@@ -131,38 +131,26 @@ QVariantMap SceneGraphTimelineModel::details(int index) const
return result;
}
void SceneGraphTimelineModel::loadData()
void SceneGraphTimelineModel::loadEvent(const QmlEvent &event, const QmlEventType &type)
{
QmlProfilerDataModel *simpleModel = modelManager()->qmlModel();
if (simpleModel->isEmpty())
return;
// combine the data of several eventtypes into two rows
const QVector<QmlEventType> &types = simpleModel->eventTypes();
foreach (const QmlEvent &event, simpleModel->events()) {
const QmlEventType &type = types[event.typeIndex()];
if (!accepted(type))
continue;
switch ((SceneGraphFrameType)type.detailType) {
case SceneGraphRendererFrame: {
// Breakdown of render times. We repeat "render" here as "net" render time. It would
// 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.timestamp() - event.number<qint64>(0) - event.number<qint64>(1)
- event.number<qint64>(2) - event.number<qint64>(3);
qint64 startTime = event.timestamp() - event.number<qint64>(0) - event.number<qint64>(1) -
event.number<qint64>(2) - event.number<qint64>(3);
startTime += insert(startTime, event.number<qint64>(0), event.typeIndex(),
RenderPreprocess);
startTime += insert(startTime, event.number<qint64>(1), event.typeIndex(),
RenderUpdate);
startTime += insert(startTime, event.number<qint64>(1), event.typeIndex(), RenderUpdate);
startTime += insert(startTime, event.number<qint64>(2), event.typeIndex(), RenderBind);
insert(startTime, event.number<qint64>(3), event.typeIndex(), RenderRender);
break;
}
case SceneGraphAdaptationLayerFrame: {
qint64 startTime = event.timestamp() - event.number<qint64>(1)
- event.number<qint64>(2);
qint64 startTime = event.timestamp() - event.number<qint64>(1) - event.number<qint64>(2);
startTime += insert(startTime, event.number<qint64>(1), event.typeIndex(), GlyphRender,
event.number<qint64>(0));
insert(startTime, event.number<qint64>(2), event.typeIndex(), GlyphStore,
@@ -175,8 +163,8 @@ void SceneGraphTimelineModel::loadData()
break;
}
case SceneGraphRenderLoopFrame: {
qint64 startTime = event.timestamp() - event.number<qint64>(0) - event.number<qint64>(1)
- event.number<qint64>(2);
qint64 startTime = event.timestamp() - event.number<qint64>(0) - event.number<qint64>(1) -
event.number<qint64>(2);
startTime += insert(startTime, event.number<qint64>(0), event.typeIndex(),
RenderThreadSync);
startTime += insert(startTime, event.number<qint64>(1), event.typeIndex(),
@@ -185,15 +173,12 @@ void SceneGraphTimelineModel::loadData()
break;
}
case SceneGraphTexturePrepare: {
qint64 startTime = event.timestamp() - event.number<qint64>(0) - event.number<qint64>(1)
- event.number<qint64>(2) - event.number<qint64>(3) - event.number<qint64>(4);
qint64 startTime = event.timestamp() - event.number<qint64>(0) - event.number<qint64>(1) -
event.number<qint64>(2) - event.number<qint64>(3) - event.number<qint64>(4);
startTime += insert(startTime, event.number<qint64>(0), event.typeIndex(), TextureBind);
startTime += insert(startTime, event.number<qint64>(1), event.typeIndex(),
TextureConvert);
startTime += insert(startTime, event.number<qint64>(2), event.typeIndex(),
TextureSwizzle);
startTime += insert(startTime, event.number<qint64>(3), event.typeIndex(),
TextureUpload);
startTime += insert(startTime, event.number<qint64>(1), event.typeIndex(), TextureConvert);
startTime += insert(startTime, event.number<qint64>(2), event.typeIndex(), TextureSwizzle);
startTime += insert(startTime, event.number<qint64>(3), event.typeIndex(), TextureUpload);
insert(startTime, event.number<qint64>(4), event.typeIndex(), TextureMipmap);
break;
}
@@ -203,13 +188,12 @@ void SceneGraphTimelineModel::loadData()
break;
}
case SceneGraphPolishAndSync: {
qint64 startTime = event.timestamp() - event.number<qint64>(0) - event.number<qint64>(1)
- event.number<qint64>(2) - event.number<qint64>(3);
qint64 startTime = event.timestamp() - event.number<qint64>(0) - event.number<qint64>(1) -
event.number<qint64>(2) - event.number<qint64>(3);
startTime += insert(startTime, event.number<qint64>(0), event.typeIndex(), Polish);
startTime += insert(startTime, event.number<qint64>(1), event.typeIndex(), Wait);
startTime += insert(startTime, event.number<qint64>(2), event.typeIndex(),
GUIThreadSync);
startTime += insert(startTime, event.number<qint64>(2), event.typeIndex(), GUIThreadSync);
insert(startTime, event.number<qint64>(3), event.typeIndex(), Animations);
break;
}
@@ -227,8 +211,10 @@ void SceneGraphTimelineModel::loadData()
}
default: break;
}
}
}
void SceneGraphTimelineModel::finalize()
{
computeNesting();
flattenLoads();
}

View File

@@ -95,8 +95,9 @@ public:
QVariantMap details(int index) const;
protected:
void loadData();
void clear();
void loadEvent(const QmlEvent &event, const QmlEventType &type) override;
void finalize() override;
void clear() override;
private:
void flattenLoads();