QmlProfiler: cleaned up old commented code

Change-Id: I1d9a16bc02770a6f1c9a742c8342b0d32e291737
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
This commit is contained in:
Christiaan Janssen
2013-06-20 16:29:37 +02:00
committed by Kai Koehne
parent 4fde52bb7a
commit a7f03f3b5b
11 changed files with 125 additions and 186 deletions

View File

@@ -60,7 +60,6 @@ qint64 AbstractTimelineModel::traceDuration() const
int AbstractTimelineModel::getState() const int AbstractTimelineModel::getState() const
{ {
// TODO: connect statechanged
return (int)m_modelManager->state(); return (int)m_modelManager->state();
} }

View File

@@ -134,12 +134,12 @@ void QmlProfilerEventsModelProxy::loadData(qint64 rangeStart, qint64 rangeEnd)
QString hash = QmlProfilerSimpleModel::getHashString(*event); QString hash = QmlProfilerSimpleModel::getHashString(*event);
if (!d->data.contains(hash)) { if (!d->data.contains(hash)) {
QmlEventStats stats = { QmlEventStats stats = {
event->bindingType,
event->displayName, event->displayName,
hash, hash,
event->data.join(QLatin1String(" ")), event->data.join(QLatin1String(" ")),
event->location, event->location,
event->eventType, event->eventType,
event->bindingType,
event->duration, event->duration,
1, //calls 1, //calls
event->duration, //minTime event->duration, //minTime
@@ -225,12 +225,12 @@ void QmlProfilerEventsModelProxy::loadData(qint64 rangeStart, qint64 rangeEnd)
// insert root event // insert root event
QmlEventStats rootEvent = { QmlEventStats rootEvent = {
0,
rootEventName, //event.displayName, rootEventName, //event.displayName,
rootEventName, // hash rootEventName, // hash
tr("Main Program"), //event.details, tr("Main Program"), //event.details,
rootEventLocation, // location rootEventLocation, // location
(int)QmlDebug::Binding, (int)QmlDebug::Binding, // event type
0, // binding type
qmlTime + 1, qmlTime + 1,
1, //calls 1, //calls
qmlTime + 1, //minTime qmlTime + 1, //minTime
@@ -322,7 +322,8 @@ void QmlProfilerEventParentsModelProxy::loadData()
0, 0,
0, 0,
QStringList() << tr("Main Program"), QStringList() << tr("Main Program"),
QmlDebug::QmlEventLocation(rootEventName, 0, 0) QmlDebug::QmlEventLocation(rootEventName, 0, 0),
0,0,0,0,0 // numericData fields
}; };
cachedEvents.insert(rootEventName, rootEvent); cachedEvents.insert(rootEventName, rootEvent);

View File

@@ -49,12 +49,12 @@ class QmlProfilerEventsModelProxy : public QObject
Q_OBJECT Q_OBJECT
public: public:
struct QmlEventStats { struct QmlEventStats {
int bindingType; // TODO: only makes sense for bindings!
QString displayName; QString displayName;
QString eventHashStr; QString eventHashStr;
QString details; QString details;
QmlDebug::QmlEventLocation location; QmlDebug::QmlEventLocation location;
int eventType; int eventType;
int bindingType;
qint64 duration; qint64 duration;
qint64 calls; qint64 calls;

View File

@@ -164,7 +164,6 @@ QmlProfilerTraceTime *QmlProfilerModelManager::traceTime() const
return d->traceTime; return d->traceTime;
} }
// TODO: rename to just "model" or something like that
QmlProfilerSimpleModel *QmlProfilerModelManager::simpleModel() const QmlProfilerSimpleModel *QmlProfilerModelManager::simpleModel() const
{ {
return d->model; return d->model;

View File

@@ -145,10 +145,6 @@ void PaintEventsModelProxy::loadData()
if (simpleModel->isEmpty()) if (simpleModel->isEmpty())
return; return;
// int lastEventId = 0;
// d->prepare();
// collect events // collect events
const QVector<QmlProfilerSimpleModel::QmlEventData> referenceList = simpleModel->getEvents(); const QVector<QmlProfilerSimpleModel::QmlEventData> referenceList = simpleModel->getEvents();
foreach (const QmlProfilerSimpleModel::QmlEventData &event, referenceList) { foreach (const QmlProfilerSimpleModel::QmlEventData &event, referenceList) {
@@ -159,10 +155,11 @@ void PaintEventsModelProxy::loadData()
// we need to correct it before appending a new event // we need to correct it before appending a new event
if (d->eventList.count() > 0) { if (d->eventList.count() > 0) {
QmlPaintEventData *lastEvent = &d->eventList[d->eventList.count()-1]; QmlPaintEventData *lastEvent = &d->eventList[d->eventList.count()-1];
if (lastEvent->startTime + lastEvent->duration >= event.startTime) if (lastEvent->startTime + lastEvent->duration >= event.startTime) {
// 1 nanosecond less to prevent overlap // 1 nanosecond less to prevent overlap
lastEvent->duration = event.startTime - lastEvent->startTime - 1; lastEvent->duration = event.startTime - lastEvent->startTime - 1;
lastEvent->framerate = 1e9/lastEvent->duration; lastEvent->framerate = 1e9/lastEvent->duration;
}
} }
QmlPaintEventData newEvent = { QmlPaintEventData newEvent = {
@@ -177,7 +174,7 @@ void PaintEventsModelProxy::loadData()
d->computeAnimationCountLimit(); d->computeAnimationCountLimit();
// qSort(d->eventList.begin(), d->eventList.end(), compareStartTimes); qSort(d->eventList.begin(), d->eventList.end(), compareStartTimes);
emit countChanged(); emit countChanged();
} }
@@ -228,6 +225,11 @@ const QString PaintEventsModelProxy::categoryLabel(int categoryIndex) const
int PaintEventsModelProxy::findFirstIndex(qint64 startTime) const int PaintEventsModelProxy::findFirstIndex(qint64 startTime) const
{
return findFirstIndexNoParents(startTime);
}
int PaintEventsModelProxy::findFirstIndexNoParents(qint64 startTime) const
{ {
if (d->eventList.isEmpty()) if (d->eventList.isEmpty())
return -1; return -1;
@@ -249,33 +251,28 @@ int PaintEventsModelProxy::findFirstIndex(qint64 startTime) const
return toIndex; return toIndex;
} }
int PaintEventsModelProxy::findFirstIndexNoParents(qint64 startTime) const
{
return findFirstIndex(startTime);
}
int PaintEventsModelProxy::findLastIndex(qint64 endTime) const int PaintEventsModelProxy::findLastIndex(qint64 endTime) const
{ {
if (d->eventList.isEmpty()) if (d->eventList.isEmpty())
return -1; return -1;
if (d->eventList.first().startTime >= endTime) if (d->eventList.first().startTime >= endTime)
return -1; return -1;
if (d->eventList.count() == 1) if (d->eventList.count() == 1)
return 0; return 0;
if (d->eventList.last().startTime <= endTime) if (d->eventList.last().startTime <= endTime)
return d->eventList.count()-1; return d->eventList.count()-1;
int fromIndex = 0; int fromIndex = 0;
int toIndex = d->eventList.count()-1; int toIndex = d->eventList.count()-1;
while (toIndex - fromIndex > 1) { while (toIndex - fromIndex > 1) {
int midIndex = (fromIndex + toIndex)/2; int midIndex = (fromIndex + toIndex)/2;
if (d->eventList[midIndex].startTime < endTime) if (d->eventList[midIndex].startTime < endTime)
fromIndex = midIndex; fromIndex = midIndex;
else else
toIndex = midIndex; toIndex = midIndex;
} }
return fromIndex; return fromIndex;
} }
int PaintEventsModelProxy::getEventType(int index) const int PaintEventsModelProxy::getEventType(int index) const
@@ -321,10 +318,6 @@ int PaintEventsModelProxy::getEventId(int index) const
QColor PaintEventsModelProxy::getColor(int index) const QColor PaintEventsModelProxy::getColor(int index) const
{ {
// TODO
// return QColor("blue");
// int ndx = getEventId(index);
// return QColor::fromHsl((ndx*25)%360, 76, 166);
double fpsFraction = d->eventList[index].framerate / 60.0; double fpsFraction = d->eventList[index].framerate / 60.0;
if (fpsFraction > 1.0) if (fpsFraction > 1.0)
fpsFraction = 1.0; fpsFraction = 1.0;

View File

@@ -78,7 +78,7 @@ void QmlProfilerSimpleModel::addRangedEvent(int type, int bindingType, qint64 st
void QmlProfilerSimpleModel::addFrameEvent(qint64 time, int framerate, int animationcount) void QmlProfilerSimpleModel::addFrameEvent(qint64 time, int framerate, int animationcount)
{ {
qint64 duration = 1e9 / framerate; qint64 duration = 1e9 / framerate;
QmlEventData eventData = {tr("Animations"), QmlDebug::Painting, QmlDebug::AnimationFrame, time, duration, QStringList(), QmlDebug::QmlEventLocation(), framerate, animationcount, 0, 0, 0}; QmlEventData eventData = {tr("Animations"), QmlDebug::Painting, QmlDebug::AnimationFrame, time - duration, duration, QStringList(), QmlDebug::QmlEventLocation(), framerate, animationcount, 0, 0, 0};
eventList.append(eventData); eventList.append(eventData);
} }

View File

@@ -61,7 +61,6 @@ public:
void prepare(); void prepare();
void computeNestingContracted(); void computeNestingContracted();
void computeExpandedLevels(); void computeExpandedLevels();
void computeBaseEventIndexes();
void buildEndTimeList(); void buildEndTimeList();
void findBindingLoops(); void findBindingLoops();
void computeRowStarts(); void computeRowStarts();
@@ -192,8 +191,6 @@ void BasicTimelineModel::loadData()
event.data.join(QLatin1String(" ")), event.data.join(QLatin1String(" ")),
event.location, event.location,
(QmlDebug::QmlEventType)event.eventType, (QmlDebug::QmlEventType)event.eventType,
// event.bindingType,
// 1,
lastEventId++ // event id lastEventId++ // event id
}; };
d->eventDict << rangeEventData; d->eventDict << rangeEventData;
@@ -204,10 +201,10 @@ void BasicTimelineModel::loadData()
QmlRangeEventStartInstance eventStartInstance = { QmlRangeEventStartInstance eventStartInstance = {
event.startTime, event.startTime,
event.duration, event.duration,
d->eventHashes.indexOf(eventHash), // event id
QmlDebug::Constants::QML_MIN_LEVEL, // displayRowExpanded; QmlDebug::Constants::QML_MIN_LEVEL, // displayRowExpanded;
QmlDebug::Constants::QML_MIN_LEVEL, // displayRowCollapsed; QmlDebug::Constants::QML_MIN_LEVEL, // displayRowCollapsed;
1, 1,
d->eventHashes.indexOf(eventHash), // event id
-1 // bindingLoopHead -1 // bindingLoopHead
}; };
d->startTimeData.append(eventStartInstance); d->startTimeData.append(eventStartInstance);
@@ -221,8 +218,6 @@ void BasicTimelineModel::loadData()
// compute nestingLevel - expanded // compute nestingLevel - expanded
d->computeExpandedLevels(); d->computeExpandedLevels();
d->computeBaseEventIndexes();
// populate endtimelist // populate endtimelist
d->buildEndTimeList(); d->buildEndTimeList();
@@ -279,7 +274,6 @@ void BasicTimelineModel::BasicTimelineModelPrivate::computeNestingContracted()
startTimeData[i].displayRowCollapsed = nestingLevels[type]; startTimeData[i].displayRowCollapsed = nestingLevels[type];
// todo: this should go to another method
if (level == QmlDebug::Constants::QML_MIN_LEVEL) { if (level == QmlDebug::Constants::QML_MIN_LEVEL) {
if (lastBaseEventEndTime < startTimeData[i].startTime) { if (lastBaseEventEndTime < startTimeData[i].startTime) {
lastBaseEventIndex = i; lastBaseEventIndex = i;
@@ -313,11 +307,6 @@ void BasicTimelineModel::BasicTimelineModelPrivate::computeExpandedLevels()
} }
} }
void BasicTimelineModel::BasicTimelineModelPrivate::computeBaseEventIndexes()
{
// TODO
}
void BasicTimelineModel::BasicTimelineModelPrivate::buildEndTimeList() void BasicTimelineModel::BasicTimelineModelPrivate::buildEndTimeList()
{ {
endTimeData.clear(); endTimeData.clear();

View File

@@ -57,7 +57,6 @@ public:
struct QmlRangeEventData struct QmlRangeEventData
{ {
QString displayName; QString displayName;
// QString eventHashStr;
QString details; QString details;
QmlDebug::QmlEventLocation location; QmlDebug::QmlEventLocation location;
QmlDebug::QmlEventType eventType; QmlDebug::QmlEventType eventType;
@@ -68,22 +67,12 @@ public:
struct QmlRangeEventStartInstance { struct QmlRangeEventStartInstance {
qint64 startTime; qint64 startTime;
qint64 duration; qint64 duration;
int eventId;
// int endTimeIndex;
// not-expanded, per type // not-expanded, per type
int displayRowExpanded; int displayRowExpanded;
int displayRowCollapsed; int displayRowCollapsed;
int baseEventIndex; // used by findfirstindex int baseEventIndex; // used by findfirstindex
// QmlRangeEventData *statsInfo;
int eventId;
// animation-related data
// int frameRate;
// int animationCount;
int bindingLoopHead; int bindingLoopHead;
}; };
@@ -92,18 +81,6 @@ public:
qint64 endTime; qint64 endTime;
}; };
// struct QmlRangedEvent {
// int bindingType; // TODO: only makes sense for bindings!
// QString displayName;
// QString eventHashStr;
// QString details;
// QmlDebug::QmlEventLocation location;
// QmlDebug::QmlEventType eventType;
// //int eventType;
// qint64 duration;
// };
BasicTimelineModel(QObject *parent = 0); BasicTimelineModel(QObject *parent = 0);
~BasicTimelineModel(); ~BasicTimelineModel();

View File

@@ -532,8 +532,6 @@ int TimelineRenderer::prevItemFromId(int modelIndex, int eventId) const
void TimelineRenderer::selectNextFromId(int modelIndex, int eventId) void TimelineRenderer::selectNextFromId(int modelIndex, int eventId)
{ {
// TODO: find next index depending on model
int eventIndex = nextItemFromId(modelIndex, eventId); int eventIndex = nextItemFromId(modelIndex, eventId);
if (eventIndex != -1) { if (eventIndex != -1) {
setSelectedModel(modelIndex); setSelectedModel(modelIndex);
@@ -543,8 +541,6 @@ void TimelineRenderer::selectNextFromId(int modelIndex, int eventId)
void TimelineRenderer::selectPrevFromId(int modelIndex, int eventId) void TimelineRenderer::selectPrevFromId(int modelIndex, int eventId)
{ {
// TODO: find next index depending on model
int eventIndex = prevItemFromId(modelIndex, eventId); int eventIndex = prevItemFromId(modelIndex, eventId);
if (eventIndex != -1) { if (eventIndex != -1) {
setSelectedModel(modelIndex); setSelectedModel(modelIndex);

View File

@@ -103,6 +103,7 @@ qint64 PixmapCacheModel::lastTimeMark() const
void PixmapCacheModel::setExpanded(int category, bool expanded) void PixmapCacheModel::setExpanded(int category, bool expanded)
{ {
Q_UNUSED(category);
d->isExpanded = expanded; d->isExpanded = expanded;
} }
@@ -129,70 +130,59 @@ const QString PixmapCacheModel::categoryLabel(int categoryIndex) const
int PixmapCacheModel::findFirstIndex(qint64 startTime) const int PixmapCacheModel::findFirstIndex(qint64 startTime) const
{ {
// TODO properly int candidate = findFirstIndexNoParents(startTime);
int candidate = -2;
for (int i=0; i < d->eventList.count(); i++)
if (d->eventList[i].startTime + d->eventList[i].duration > startTime) {
candidate = i;
break;
}
if (candidate == -1)
return 0;
if (candidate == -2)
return d->eventList.count() - 1;
return candidate; return candidate;
} }
int PixmapCacheModel::findFirstIndexNoParents(qint64 startTime) const int PixmapCacheModel::findFirstIndexNoParents(qint64 startTime) const
{ {
// TODO properly if (d->eventList.isEmpty())
return findFirstIndex(startTime); return -1;
if (d->eventList.count() == 1 || d->eventList.first().startTime+d->eventList.first().duration >= startTime)
return 0;
else
if (d->eventList.last().startTime+d->eventList.last().duration <= startTime)
return -1;
// int candidate = -1; int fromIndex = 0;
// // in the "endtime" list, find the first event that ends after startTime int toIndex = d->eventList.count()-1;
// if (d->endTimeData.isEmpty()) while (toIndex - fromIndex > 1) {
// return 0; // -1 int midIndex = (fromIndex + toIndex)/2;
// if (d->endTimeData.count() == 1 || d->endTimeData.first().endTime >= startTime) if (d->eventList[midIndex].startTime + d->eventList[midIndex].duration < startTime)
// candidate = 0; fromIndex = midIndex;
// else else
// if (d->endTimeData.last().endTime <= startTime) toIndex = midIndex;
// return 0; // -1 }
return toIndex;
// if (candidate == -1) {
// int fromIndex = 0;
// int toIndex = d->endTimeData.count()-1;
// while (toIndex - fromIndex > 1) {
// int midIndex = (fromIndex + toIndex)/2;
// if (d->endTimeData[midIndex].endTime < startTime)
// fromIndex = midIndex;
// else
// toIndex = midIndex;
// }
// candidate = toIndex;
// }
// int ndx = d->endTimeData[candidate].startTimeIndex;
// return ndx;
} }
int PixmapCacheModel::findLastIndex(qint64 endTime) const int PixmapCacheModel::findLastIndex(qint64 endTime) const
{ {
// TODO properly if (d->eventList.isEmpty())
int candidate = 0; return -1;
for (int i = d->eventList.count()-1; i >= 0; i--) if (d->eventList.first().startTime >= endTime)
if (d->eventList[i].startTime < endTime) { return -1;
candidate = i; if (d->eventList.count() == 1)
break; return 0;
} if (d->eventList.last().startTime <= endTime)
return candidate; return d->eventList.count()-1;
int fromIndex = 0;
int toIndex = d->eventList.count()-1;
while (toIndex - fromIndex > 1) {
int midIndex = (fromIndex + toIndex)/2;
if (d->eventList[midIndex].startTime < endTime)
fromIndex = midIndex;
else
toIndex = midIndex;
}
return fromIndex;
} }
int PixmapCacheModel::getEventType(int index) const int PixmapCacheModel::getEventType(int index) const
{ {
Q_UNUSED(index);
return QmlDebug::PixmapCacheEvent; return QmlDebug::PixmapCacheEvent;
} }
@@ -263,6 +253,7 @@ QString getFilenameOnly(QString absUrl)
const QVariantList PixmapCacheModel::getLabelsForCategory(int category) const const QVariantList PixmapCacheModel::getLabelsForCategory(int category) const
{ {
Q_UNUSED(category);
QVariantList result; QVariantList result;
if (d->isExpanded && !isEmpty()) { if (d->isExpanded && !isEmpty()) {

View File

@@ -111,12 +111,13 @@ qint64 SceneGraphTimelineModel::lastTimeMark() const
void SceneGraphTimelineModel::setExpanded(int category, bool expanded) void SceneGraphTimelineModel::setExpanded(int category, bool expanded)
{ {
d->isExpanded = expanded; Q_UNUSED(category);
d->isExpanded = expanded;
} }
int SceneGraphTimelineModel::categoryDepth(int categoryIndex) const int SceneGraphTimelineModel::categoryDepth(int categoryIndex) const
{ {
// TODO Q_UNUSED(categoryIndex);
if (isEmpty()) if (isEmpty())
return 1; return 1;
return 3; return 3;
@@ -135,74 +136,64 @@ const QString SceneGraphTimelineModel::categoryLabel(int categoryIndex) const
int SceneGraphTimelineModel::findFirstIndex(qint64 startTime) const int SceneGraphTimelineModel::findFirstIndex(qint64 startTime) const
{ {
// TODO properly int candidate = findFirstIndexNoParents(startTime);
int candidate = -2; // because there's two threads synchronized, the right index could be one off
for (int i=0; i < d->eventList.count(); i++) if (candidate > 0 && d->eventList[candidate-1].startTime + d->eventList[candidate-1].duration >= startTime)
if (d->eventList[i].startTime + d->eventList[i].duration > startTime) { return candidate - 1;
candidate = i;
break;
}
if (candidate == -1)
return 0;
if (candidate == -2)
return d->eventList.count() - 1;
return candidate; return candidate;
} }
int SceneGraphTimelineModel::findFirstIndexNoParents(qint64 startTime) const int SceneGraphTimelineModel::findFirstIndexNoParents(qint64 startTime) const
{ {
// TODO properly if (d->eventList.isEmpty())
return findFirstIndex(startTime); return -1;
if (d->eventList.count() == 1 || d->eventList.first().startTime+d->eventList.first().duration >= startTime)
return 0;
else
if (d->eventList.last().startTime+d->eventList.last().duration <= startTime)
return -1;
// int candidate = -1; int fromIndex = 0;
// // in the "endtime" list, find the first event that ends after startTime int toIndex = d->eventList.count()-1;
// if (d->endTimeData.isEmpty()) while (toIndex - fromIndex > 1) {
// return 0; // -1 int midIndex = (fromIndex + toIndex)/2;
// if (d->endTimeData.count() == 1 || d->endTimeData.first().endTime >= startTime) if (d->eventList[midIndex].startTime + d->eventList[midIndex].duration < startTime)
// candidate = 0; fromIndex = midIndex;
// else else
// if (d->endTimeData.last().endTime <= startTime) toIndex = midIndex;
// return 0; // -1 }
return toIndex;
// if (candidate == -1) {
// int fromIndex = 0;
// int toIndex = d->endTimeData.count()-1;
// while (toIndex - fromIndex > 1) {
// int midIndex = (fromIndex + toIndex)/2;
// if (d->endTimeData[midIndex].endTime < startTime)
// fromIndex = midIndex;
// else
// toIndex = midIndex;
// }
// candidate = toIndex;
// }
// int ndx = d->endTimeData[candidate].startTimeIndex;
// return ndx;
} }
int SceneGraphTimelineModel::findLastIndex(qint64 endTime) const int SceneGraphTimelineModel::findLastIndex(qint64 endTime) const
{ {
// TODO properly if (d->eventList.isEmpty())
int candidate = 0; return -1;
for (int i = d->eventList.count()-1; i >= 0; i--) if (d->eventList.first().startTime >= endTime)
if (d->eventList[i].startTime < endTime) { return -1;
candidate = i; if (d->eventList.count() == 1)
break; return 0;
} if (d->eventList.last().startTime <= endTime)
return candidate; return d->eventList.count()-1;
int fromIndex = 0;
int toIndex = d->eventList.count()-1;
while (toIndex - fromIndex > 1) {
int midIndex = (fromIndex + toIndex)/2;
if (d->eventList[midIndex].startTime < endTime)
fromIndex = midIndex;
else
toIndex = midIndex;
}
return fromIndex;
} }
int SceneGraphTimelineModel::getEventType(int index) const int SceneGraphTimelineModel::getEventType(int index) const
{ {
// TODO fix Q_UNUSED(index);
return QmlDebug::PixmapCacheEvent; return QmlDebug::SceneGraphFrameEvent;
//return QmlDebug::SceneGraphFrameEvent;
// return 0;
} }
int SceneGraphTimelineModel::getEventCategory(int index) const int SceneGraphTimelineModel::getEventCategory(int index) const
@@ -259,6 +250,7 @@ QColor SceneGraphTimelineModel::getColor(int index) const
float SceneGraphTimelineModel::getHeight(int index) const float SceneGraphTimelineModel::getHeight(int index) const
{ {
Q_UNUSED(index);
return 1.0f; return 1.0f;
} }
@@ -275,6 +267,7 @@ QString labelForSGType(int t)
const QVariantList SceneGraphTimelineModel::getLabelsForCategory(int category) const const QVariantList SceneGraphTimelineModel::getLabelsForCategory(int category) const
{ {
Q_UNUSED(category);
QVariantList result; QVariantList result;
if (d->isExpanded && !isEmpty()) { if (d->isExpanded && !isEmpty()) {
@@ -448,6 +441,7 @@ void SceneGraphTimelineModel::loadData()
d->eventList[lastRenderEvent].timing[15] = event.numericData1; d->eventList[lastRenderEvent].timing[15] = event.numericData1;
break; break;
} }
default: break;
} }
} }
} }