QmlProfiler: show empty trace

In the case that the application did not generate any event
after running the profiler, still show an empty trace.
Otherwise the user will think that the profiler didn't work.

Change-Id: Idd15225270d55d834719f66387864433fcb9026d
Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
This commit is contained in:
Christiaan Janssen
2012-05-11 16:45:47 +02:00
parent a9680ec23c
commit af72e4bb3f
5 changed files with 32 additions and 14 deletions

View File

@@ -176,6 +176,7 @@ Rectangle {
function clearAll() {
clearDisplay();
elapsedTime = 0;
}
function nextEvent() {

View File

@@ -69,7 +69,7 @@ Item {
states: [
// no data available
State {
when: (root.eventCount == 0) && !root.recordingEnabled
when: (root.eventCount == 0) && (elapsedTime > 0) && !root.recordingEnabled
PropertyChanges {
target: statusDisplay
visible: true

View File

@@ -800,6 +800,8 @@ void QmlProfilerDataModel::complete()
d->postProcess();
} else
if (currentState() == Empty) {
d->v8DataModel->collectV8Statistics();
compileStatistics(traceStartTime(), traceEndTime());
setState(Done);
} else {
emit error("Unexpected complete signal in data model");
@@ -819,7 +821,6 @@ void QmlProfilerDataModel::QmlProfilerDataModelPrivate::postProcess()
q->reloadDetails();
prepareForDisplay();
q->compileStatistics(q->traceStartTime(), q->traceEndTime());
}
q->setState(Done);
}
@@ -1063,9 +1064,18 @@ void QmlProfilerDataModel::QmlProfilerDataModelPrivate::linkEndsToStarts()
void QmlProfilerDataModel::compileStatistics(qint64 startTime, qint64 endTime)
{
d->clearStatistics();
if (traceDuration() > 0) {
if (count() > 0) {
d->redoTree(startTime, endTime);
d->computeMedianTime(startTime, endTime);
d->findBindingLoops(startTime, endTime);
} else {
d->insertQmlRootEvent();
QmlRangeEventData *listedRootEvent = d->rangeEventDictionary.value(rootEventName());
listedRootEvent->calls = 1;
listedRootEvent->percentOfTime = 100;
}
}
}
void QmlProfilerDataModel::QmlProfilerDataModelPrivate::clearStatistics()
@@ -1074,7 +1084,7 @@ void QmlProfilerDataModel::QmlProfilerDataModelPrivate::clearStatistics()
foreach (QmlRangeEventData *eventDescription, rangeEventDictionary.values()) {
eventDescription->calls = 0;
// maximum possible value
eventDescription->minTime = endInstanceList.last().endTime;
eventDescription->minTime = traceEndTime;
eventDescription->maxTime = 0;
eventDescription->medianTime = 0;
eventDescription->duration = 0;
@@ -1661,10 +1671,6 @@ void QmlProfilerDataModel::setState(QmlProfilerDataModel::State state)
d->listState = state;
emit stateChanged();
// special: if we were done with an empty list, clean internal data and go back to empty
if (d->listState == Done && isEmpty()) {
clear();
}
return;
}

View File

@@ -237,6 +237,15 @@ void QV8ProfilerDataModel::QV8ProfilerDataModelPrivate::collectV8Statistics()
v8event->eventId = index++;
}
v8RootEvent.eventId = v8EventHash[rootEventHash]->eventId;
} else {
// On empty data, still add a fake root event
clearV8RootEvent();
v8RootEvent.totalPercent = 100;
QString rootEventHash = QmlProfilerDataModel::getHashStringForV8Event(
QmlProfilerDataModel::rootEventName(),
QmlProfilerDataModel::rootEventDescription());
v8EventHash[rootEventHash] = new QV8EventData;
*v8EventHash[rootEventHash] = v8RootEvent;
}
}

View File

@@ -109,9 +109,11 @@ void TimelineRenderer::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWid
int firstIndex = m_profilerDataModel->findFirstIndex(m_startTime);
int lastIndex = m_profilerDataModel->findLastIndex(m_endTime);
if (lastIndex < m_profilerDataModel->count()) {
drawItemsToPainter(p, firstIndex, lastIndex);
drawSelectionBoxes(p, firstIndex, lastIndex);
drawBindingLoopMarkers(p, firstIndex, lastIndex);
}
m_lastStartTime = m_startTime;
m_lastEndTime = m_endTime;
@@ -357,7 +359,7 @@ void TimelineRenderer::manageHovered(int x, int y)
// find if there's items in the time range
int eventFrom = m_profilerDataModel->findFirstIndex(time);
int eventTo = m_profilerDataModel->findLastIndex(time);
if (eventTo < eventFrom) {
if (eventTo < eventFrom || eventTo >= m_profilerDataModel->count()) {
m_currentSelection.eventIndex = -1;
return;
}