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
{
// TODO: connect statechanged
return (int)m_modelManager->state();
}

View File

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

View File

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

View File

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

View File

@@ -145,10 +145,6 @@ void PaintEventsModelProxy::loadData()
if (simpleModel->isEmpty())
return;
// int lastEventId = 0;
// d->prepare();
// collect events
const QVector<QmlProfilerSimpleModel::QmlEventData> referenceList = simpleModel->getEvents();
foreach (const QmlProfilerSimpleModel::QmlEventData &event, referenceList) {
@@ -159,11 +155,12 @@ void PaintEventsModelProxy::loadData()
// we need to correct it before appending a new event
if (d->eventList.count() > 0) {
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
lastEvent->duration = event.startTime - lastEvent->startTime - 1;
lastEvent->framerate = 1e9/lastEvent->duration;
}
}
QmlPaintEventData newEvent = {
event.startTime,
@@ -177,7 +174,7 @@ void PaintEventsModelProxy::loadData()
d->computeAnimationCountLimit();
// qSort(d->eventList.begin(), d->eventList.end(), compareStartTimes);
qSort(d->eventList.begin(), d->eventList.end(), compareStartTimes);
emit countChanged();
}
@@ -228,6 +225,11 @@ const QString PaintEventsModelProxy::categoryLabel(int categoryIndex) const
int PaintEventsModelProxy::findFirstIndex(qint64 startTime) const
{
return findFirstIndexNoParents(startTime);
}
int PaintEventsModelProxy::findFirstIndexNoParents(qint64 startTime) const
{
if (d->eventList.isEmpty())
return -1;
@@ -249,11 +251,6 @@ int PaintEventsModelProxy::findFirstIndex(qint64 startTime) const
return toIndex;
}
int PaintEventsModelProxy::findFirstIndexNoParents(qint64 startTime) const
{
return findFirstIndex(startTime);
}
int PaintEventsModelProxy::findLastIndex(qint64 endTime) const
{
if (d->eventList.isEmpty())
@@ -321,10 +318,6 @@ int PaintEventsModelProxy::getEventId(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;
if (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)
{
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);
}

View File

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

View File

@@ -57,7 +57,6 @@ public:
struct QmlRangeEventData
{
QString displayName;
// QString eventHashStr;
QString details;
QmlDebug::QmlEventLocation location;
QmlDebug::QmlEventType eventType;
@@ -68,22 +67,12 @@ public:
struct QmlRangeEventStartInstance {
qint64 startTime;
qint64 duration;
// int endTimeIndex;
int eventId;
// not-expanded, per type
int displayRowExpanded;
int displayRowCollapsed;
int baseEventIndex; // used by findfirstindex
// QmlRangeEventData *statsInfo;
int eventId;
// animation-related data
// int frameRate;
// int animationCount;
int bindingLoopHead;
};
@@ -92,18 +81,6 @@ public:
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();

View File

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

View File

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

View File

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