forked from qt-creator/qt-creator
QmlProfiler: refactor postprocess step in internal statistics
Change-Id: Id6ea03161ccad92a27a664e84f56b2a49400be91 Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
This commit is contained in:
@@ -167,7 +167,6 @@ public:
|
|||||||
|
|
||||||
// file to load
|
// file to load
|
||||||
QString m_filename;
|
QString m_filename;
|
||||||
ParsingStatus m_parsingStatus;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -177,7 +176,6 @@ public:
|
|||||||
QmlProfilerEventList::QmlProfilerEventList(QObject *parent) :
|
QmlProfilerEventList::QmlProfilerEventList(QObject *parent) :
|
||||||
QObject(parent), d(new QmlProfilerEventListPrivate(this))
|
QObject(parent), d(new QmlProfilerEventListPrivate(this))
|
||||||
{
|
{
|
||||||
d->m_parsingStatus = DoneStatus;
|
|
||||||
setObjectName("QmlProfilerEventStatistics");
|
setObjectName("QmlProfilerEventStatistics");
|
||||||
|
|
||||||
d->m_traceEndTime = 0;
|
d->m_traceEndTime = 0;
|
||||||
@@ -243,11 +241,11 @@ const QV8EventDescriptions& QmlProfilerEventList::getV8Events() const
|
|||||||
void QmlProfilerEventList::addRangedEvent(int type, qint64 startTime, qint64 length,
|
void QmlProfilerEventList::addRangedEvent(int type, qint64 startTime, qint64 length,
|
||||||
const QStringList &data, const QString &fileName, int line)
|
const QStringList &data, const QString &fileName, int line)
|
||||||
{
|
{
|
||||||
setParsingStatus(GettingDataStatus);
|
|
||||||
|
|
||||||
const QChar colon = QLatin1Char(':');
|
const QChar colon = QLatin1Char(':');
|
||||||
QString displayName, location, details;
|
QString displayName, location, details;
|
||||||
|
|
||||||
|
emit processingData();
|
||||||
|
|
||||||
if (fileName.isEmpty()) {
|
if (fileName.isEmpty()) {
|
||||||
displayName = tr("<bytecode>");
|
displayName = tr("<bytecode>");
|
||||||
location = QString("--:%1:%2").arg(QString::number(type), data.join(" "));
|
location = QString("--:%1:%2").arg(QString::number(type), data.join(" "));
|
||||||
@@ -468,9 +466,6 @@ void QmlProfilerEventList::compileStatistics()
|
|||||||
if (!d->m_typeCounts[typeNumber]->eventIds.contains(eventStartData.description->eventId))
|
if (!d->m_typeCounts[typeNumber]->eventIds.contains(eventStartData.description->eventId))
|
||||||
d->m_typeCounts[typeNumber]->eventIds << eventStartData.description->eventId;
|
d->m_typeCounts[typeNumber]->eventIds << eventStartData.description->eventId;
|
||||||
}
|
}
|
||||||
|
|
||||||
// continue postprocess
|
|
||||||
postProcess();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlProfilerEventList::sortStartTimes()
|
void QmlProfilerEventList::sortStartTimes()
|
||||||
@@ -513,9 +508,6 @@ void QmlProfilerEventList::sortStartTimes()
|
|||||||
// link back the endTimes
|
// link back the endTimes
|
||||||
for (int i = 0; i < d->m_startTimeSortedList.length(); i++)
|
for (int i = 0; i < d->m_startTimeSortedList.length(); i++)
|
||||||
d->m_endTimeSortedList[d->m_startTimeSortedList[i].endTimeIndex].startTimeIndex = i;
|
d->m_endTimeSortedList[d->m_startTimeSortedList[i].endTimeIndex].startTimeIndex = i;
|
||||||
|
|
||||||
// continue postprocess
|
|
||||||
postProcess();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlProfilerEventList::sortEndTimes()
|
void QmlProfilerEventList::sortEndTimes()
|
||||||
@@ -562,9 +554,6 @@ void QmlProfilerEventList::sortEndTimes()
|
|||||||
// link back the startTimes
|
// link back the startTimes
|
||||||
for (int i = 0; i < d->m_endTimeSortedList.length(); i++)
|
for (int i = 0; i < d->m_endTimeSortedList.length(); i++)
|
||||||
d->m_startTimeSortedList[d->m_endTimeSortedList[i].startTimeIndex].endTimeIndex = i;
|
d->m_startTimeSortedList[d->m_endTimeSortedList[i].startTimeIndex].endTimeIndex = i;
|
||||||
|
|
||||||
// continue postprocess
|
|
||||||
postProcess();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlProfilerEventList::computeNestingLevels()
|
void QmlProfilerEventList::computeNestingLevels()
|
||||||
@@ -632,50 +621,12 @@ void QmlProfilerEventList::computeNestingDepth()
|
|||||||
|
|
||||||
void QmlProfilerEventList::postProcess()
|
void QmlProfilerEventList::postProcess()
|
||||||
{
|
{
|
||||||
// Todo: collapse all this
|
sortStartTimes();
|
||||||
switch (d->m_parsingStatus) {
|
sortEndTimes();
|
||||||
case GettingDataStatus: {
|
computeLevels();
|
||||||
setParsingStatus(SortingListsStatus);
|
compileStatistics();
|
||||||
QTimer::singleShot(50, this, SLOT(sortStartTimes()));
|
linkEndsToStarts();
|
||||||
break;
|
emit dataReady();
|
||||||
}
|
|
||||||
case SortingEndsStatus: {
|
|
||||||
setParsingStatus(SortingListsStatus);
|
|
||||||
QTimer::singleShot(50, this, SLOT(sortEndTimes()));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case SortingListsStatus: {
|
|
||||||
setParsingStatus(ComputingLevelsStatus);
|
|
||||||
QTimer::singleShot(50, this, SLOT(computeLevels()));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case ComputingLevelsStatus: {
|
|
||||||
setParsingStatus(CompilingStatisticsStatus);
|
|
||||||
QTimer::singleShot(50, this, SLOT(compileStatistics()));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case CompilingStatisticsStatus: {
|
|
||||||
linkEndsToStarts();
|
|
||||||
setParsingStatus(DoneStatus);
|
|
||||||
emit dataReady();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default: break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void QmlProfilerEventList::setParsingStatus(ParsingStatus ps)
|
|
||||||
{
|
|
||||||
if (d->m_parsingStatus != ps) {
|
|
||||||
d->m_parsingStatus = ps;
|
|
||||||
emit parsingStatusChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ParsingStatus QmlProfilerEventList::getParsingStatus() const
|
|
||||||
{
|
|
||||||
return d->m_parsingStatus;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlProfilerEventList::linkEndsToStarts()
|
void QmlProfilerEventList::linkEndsToStarts()
|
||||||
@@ -688,8 +639,6 @@ void QmlProfilerEventList::computeLevels()
|
|||||||
{
|
{
|
||||||
computeNestingLevels();
|
computeNestingLevels();
|
||||||
computeNestingDepth();
|
computeNestingDepth();
|
||||||
// continue postprocess
|
|
||||||
postProcess();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// get list of events between A and B:
|
// get list of events between A and B:
|
||||||
@@ -930,7 +879,7 @@ void QmlProfilerEventList::load()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setParsingStatus(GettingDataStatus);
|
emit processingData();
|
||||||
|
|
||||||
// erase current
|
// erase current
|
||||||
clear();
|
clear();
|
||||||
@@ -1164,8 +1113,6 @@ void QmlProfilerEventList::load()
|
|||||||
|
|
||||||
emit countChanged();
|
emit countChanged();
|
||||||
|
|
||||||
setParsingStatus(SortingEndsStatus);
|
|
||||||
|
|
||||||
descriptionBuffer.clear();
|
descriptionBuffer.clear();
|
||||||
|
|
||||||
d->collectV8Statistics();
|
d->collectV8Statistics();
|
||||||
|
|||||||
@@ -81,15 +81,6 @@ typedef QHash<QString, QmlEventData *> QmlEventHash;
|
|||||||
typedef QList<QmlEventData *> QmlEventDescriptions;
|
typedef QList<QmlEventData *> QmlEventDescriptions;
|
||||||
typedef QList<QV8EventData *> QV8EventDescriptions;
|
typedef QList<QV8EventData *> QV8EventDescriptions;
|
||||||
|
|
||||||
enum ParsingStatus {
|
|
||||||
GettingDataStatus = 0,
|
|
||||||
SortingListsStatus = 1,
|
|
||||||
SortingEndsStatus = 2,
|
|
||||||
ComputingLevelsStatus = 3,
|
|
||||||
CompilingStatisticsStatus = 4,
|
|
||||||
DoneStatus = 5
|
|
||||||
};
|
|
||||||
|
|
||||||
class QMLJSDEBUGCLIENT_EXPORT QmlProfilerEventList : public QObject
|
class QMLJSDEBUGCLIENT_EXPORT QmlProfilerEventList : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -110,8 +101,6 @@ public:
|
|||||||
Q_INVOKABLE qint64 lastTimeMark() const;
|
Q_INVOKABLE qint64 lastTimeMark() const;
|
||||||
|
|
||||||
Q_INVOKABLE int count() const;
|
Q_INVOKABLE int count() const;
|
||||||
void setParsingStatus(ParsingStatus ps);
|
|
||||||
Q_INVOKABLE ParsingStatus getParsingStatus() const;
|
|
||||||
|
|
||||||
// data access
|
// data access
|
||||||
Q_INVOKABLE qint64 getStartTime(int index) const;
|
Q_INVOKABLE qint64 getStartTime(int index) const;
|
||||||
@@ -139,9 +128,9 @@ public:
|
|||||||
signals:
|
signals:
|
||||||
void dataReady();
|
void dataReady();
|
||||||
void countChanged();
|
void countChanged();
|
||||||
void parsingStatusChanged();
|
|
||||||
void error(const QString &error);
|
void error(const QString &error);
|
||||||
void dataClear();
|
void dataClear();
|
||||||
|
void processingData();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void clear();
|
void clear();
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ Rectangle {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onParsingStatusChanged: {
|
onProcessingData: {
|
||||||
root.dataAvailable = false;
|
root.dataAvailable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -104,7 +104,6 @@ QmlProfilerApplication::QmlProfilerApplication(int &argc, char **argv) :
|
|||||||
|
|
||||||
connect(&m_eventList, SIGNAL(error(QString)), this, SLOT(logError(QString)));
|
connect(&m_eventList, SIGNAL(error(QString)), this, SLOT(logError(QString)));
|
||||||
connect(&m_eventList, SIGNAL(dataReady()), this, SLOT(traceFinished()));
|
connect(&m_eventList, SIGNAL(dataReady()), this, SLOT(traceFinished()));
|
||||||
connect(&m_eventList, SIGNAL(parsingStatusChanged()), this, SLOT(parsingStatusChanged()));
|
|
||||||
connect(this, SIGNAL(done()), &m_eventList, SLOT(complete()));
|
connect(this, SIGNAL(done()), &m_eventList, SLOT(complete()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -339,32 +338,6 @@ void QmlProfilerApplication::traceFinished()
|
|||||||
quit();
|
quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlProfilerApplication::parsingStatusChanged()
|
|
||||||
{
|
|
||||||
if (m_verbose) {
|
|
||||||
switch (m_eventList.getParsingStatus()) {
|
|
||||||
case GettingDataStatus:
|
|
||||||
logStatus("Parsing - Getting data ...");
|
|
||||||
break;
|
|
||||||
case SortingListsStatus:
|
|
||||||
logStatus("Parsing - Sorting ...");
|
|
||||||
break;
|
|
||||||
case SortingEndsStatus:
|
|
||||||
logStatus("Parsing - Sorting done");
|
|
||||||
break;
|
|
||||||
case ComputingLevelsStatus:
|
|
||||||
logStatus("Parsing - Computing levels ...");
|
|
||||||
break;
|
|
||||||
case CompilingStatisticsStatus:
|
|
||||||
logStatus("Parsing - Computing statistics ...");
|
|
||||||
break;
|
|
||||||
case DoneStatus:
|
|
||||||
logStatus("Parsing - Done.");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void QmlProfilerApplication::recordingChanged()
|
void QmlProfilerApplication::recordingChanged()
|
||||||
{
|
{
|
||||||
QTextStream err(stderr);
|
QTextStream err(stderr);
|
||||||
|
|||||||
@@ -72,7 +72,6 @@ private slots:
|
|||||||
|
|
||||||
void traceClientEnabled();
|
void traceClientEnabled();
|
||||||
void traceFinished();
|
void traceFinished();
|
||||||
void parsingStatusChanged();
|
|
||||||
void recordingChanged();
|
void recordingChanged();
|
||||||
|
|
||||||
void print(const QString &line);
|
void print(const QString &line);
|
||||||
|
|||||||
Reference in New Issue
Block a user