forked from qt-creator/qt-creator
QmlProfiler: remove V8 tab
V8 is gone long enough to stop supporting it. Change-Id: If086925359097a69ffab2b2eba4de6f63bd5195e Reviewed-by: Ulf Hermann <ulf.hermann@theqtcompany.com> Reviewed-by: Alessandro Portale <alessandro.portale@theqtcompany.com>
This commit is contained in:
@@ -29,9 +29,7 @@ SOURCES += \
|
||||
qmlprofilertracefile.cpp \
|
||||
qmlprofilertraceview.cpp \
|
||||
qmlprofilertreeview.cpp \
|
||||
qmlprofilerviewmanager.cpp \
|
||||
qv8profilerdatamodel.cpp \
|
||||
qv8profilereventview.cpp
|
||||
qmlprofilerviewmanager.cpp
|
||||
|
||||
HEADERS += \
|
||||
abstractqmlprofilerrunner.h \
|
||||
@@ -62,9 +60,7 @@ HEADERS += \
|
||||
qmlprofilertracefile.h \
|
||||
qmlprofilertraceview.h \
|
||||
qmlprofilertreeview.h \
|
||||
qmlprofilerviewmanager.h \
|
||||
qv8profilerdatamodel.h \
|
||||
qv8profilereventview.h
|
||||
qmlprofilerviewmanager.h
|
||||
|
||||
RESOURCES += \
|
||||
qml/qmlprofiler.qrc
|
||||
|
||||
@@ -47,8 +47,6 @@ QtcPlugin {
|
||||
"qmlprofilertraceview.cpp", "qmlprofilertraceview.h",
|
||||
"qmlprofilertreeview.cpp", "qmlprofilertreeview.h",
|
||||
"qmlprofilerviewmanager.cpp", "qmlprofilerviewmanager.h",
|
||||
"qv8profilerdatamodel.cpp", "qv8profilerdatamodel.h",
|
||||
"qv8profilereventview.h", "qv8profilereventview.cpp",
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
|
||||
#include <qmldebug/qmldebugclient.h>
|
||||
#include <qmldebug/qmlprofilertraceclient.h>
|
||||
#include <qmldebug/qv8profilerclient.h>
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
#include <QPointer>
|
||||
@@ -56,7 +55,6 @@ public:
|
||||
|
||||
QmlDebugConnection *connection;
|
||||
QPointer<QmlProfilerTraceClient> qmlclientplugin;
|
||||
QPointer<QV8ProfilerClient> v8clientplugin;
|
||||
|
||||
QTimer connectionTimer;
|
||||
int connectionAttempts;
|
||||
@@ -70,7 +68,6 @@ public:
|
||||
QString ostDevice;
|
||||
QString sysroot;
|
||||
|
||||
bool v8DataReady;
|
||||
bool qmlDataReady;
|
||||
|
||||
QmlProfilerModelManager *modelManager;
|
||||
@@ -85,7 +82,6 @@ QmlProfilerClientManager::QmlProfilerClientManager(QObject *parent) :
|
||||
|
||||
d->connection = 0;
|
||||
d->connectionAttempts = 0;
|
||||
d->v8DataReady = false;
|
||||
d->qmlDataReady = false;
|
||||
|
||||
d->modelManager = 0;
|
||||
@@ -98,8 +94,6 @@ QmlProfilerClientManager::~QmlProfilerClientManager()
|
||||
{
|
||||
delete d->connection;
|
||||
delete d->qmlclientplugin.data();
|
||||
delete d->v8clientplugin.data();
|
||||
|
||||
delete d;
|
||||
}
|
||||
|
||||
@@ -131,8 +125,6 @@ void QmlProfilerClientManager::clearBufferedData()
|
||||
{
|
||||
if (d->qmlclientplugin)
|
||||
d->qmlclientplugin.data()->clearData();
|
||||
if (d->v8clientplugin)
|
||||
d->v8clientplugin.data()->clearData();
|
||||
}
|
||||
|
||||
void QmlProfilerClientManager::discardPendingData()
|
||||
@@ -165,8 +157,6 @@ void QmlProfilerClientManager::enableServices()
|
||||
delete d->qmlclientplugin.data();
|
||||
d->qmlclientplugin = new QmlProfilerTraceClient(d->connection,
|
||||
d->profilerState->recordingFeatures());
|
||||
delete d->v8clientplugin.data();
|
||||
d->v8clientplugin = new QV8ProfilerClient(d->connection);
|
||||
connectClientSignals();
|
||||
}
|
||||
|
||||
@@ -196,15 +186,6 @@ void QmlProfilerClientManager::connectClientSignals()
|
||||
connect(d->profilerState, SIGNAL(recordingFeaturesChanged(quint64)),
|
||||
d->qmlclientplugin.data(), SLOT(setFeatures(quint64)));
|
||||
}
|
||||
if (d->v8clientplugin) {
|
||||
connect(d->v8clientplugin.data(), SIGNAL(complete()), this, SLOT(v8Complete()));
|
||||
connect(d->v8clientplugin.data(),
|
||||
SIGNAL(v8range(int,QString,QString,int,double,double)),
|
||||
d->modelManager,
|
||||
SLOT(addV8Event(int,QString,QString,int,double,double)));
|
||||
connect(d->v8clientplugin.data(), SIGNAL(enabledChanged()),
|
||||
d->v8clientplugin.data(), SLOT(sendRecordingStatus()));
|
||||
}
|
||||
}
|
||||
|
||||
void QmlProfilerClientManager::disconnectClientSignals()
|
||||
@@ -230,15 +211,6 @@ void QmlProfilerClientManager::disconnectClientSignals()
|
||||
disconnect(d->profilerState, SIGNAL(recordingFeaturesChanged(quint64)),
|
||||
d->qmlclientplugin.data(), SLOT(setFeatures(quint64)));
|
||||
}
|
||||
if (d->v8clientplugin) {
|
||||
disconnect(d->v8clientplugin.data(), SIGNAL(complete()), this, SLOT(v8Complete()));
|
||||
disconnect(d->v8clientplugin.data(),
|
||||
SIGNAL(v8range(int,QString,QString,int,double,double)),
|
||||
d->modelManager,
|
||||
SLOT(addV8Event(int,QString,QString,int,double,double)));
|
||||
disconnect(d->v8clientplugin.data(), SIGNAL(enabledChanged()),
|
||||
d->v8clientplugin.data(), SLOT(sendRecordingStatus()));
|
||||
}
|
||||
}
|
||||
|
||||
void QmlProfilerClientManager::connectToClient()
|
||||
@@ -341,35 +313,15 @@ void QmlProfilerClientManager::qmlComplete(qint64 maximumTime)
|
||||
{
|
||||
d->modelManager->traceTime()->increaseEndTime(maximumTime);
|
||||
d->qmlDataReady = true;
|
||||
if (!d->v8clientplugin ||
|
||||
d->v8clientplugin.data()->state() != QmlDebugClient::Enabled ||
|
||||
d->v8DataReady) {
|
||||
emit dataReadyForProcessing();
|
||||
// once complete is sent, reset the flags
|
||||
d->qmlDataReady = false;
|
||||
d->v8DataReady = false;
|
||||
}
|
||||
}
|
||||
|
||||
void QmlProfilerClientManager::v8Complete()
|
||||
{
|
||||
d->v8DataReady = true;
|
||||
if (!d->qmlclientplugin ||
|
||||
d->qmlclientplugin.data()->state() != QmlDebugClient::Enabled ||
|
||||
d->qmlDataReady) {
|
||||
emit dataReadyForProcessing();
|
||||
// once complete is sent, reset the flags
|
||||
d->v8DataReady = false;
|
||||
d->qmlDataReady = false;
|
||||
}
|
||||
emit dataReadyForProcessing();
|
||||
// once complete is sent, reset the flags
|
||||
d->qmlDataReady = false;
|
||||
}
|
||||
|
||||
void QmlProfilerClientManager::stopClientsRecording()
|
||||
{
|
||||
if (d->qmlclientplugin)
|
||||
d->qmlclientplugin.data()->setRecording(false);
|
||||
if (d->v8clientplugin)
|
||||
d->v8clientplugin.data()->setRecording(false);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
@@ -419,17 +371,13 @@ void QmlProfilerClientManager::clientRecordingChanged()
|
||||
if (d->profilerState->currentState() == QmlProfilerStateManager::AppRunning) {
|
||||
if (d->qmlclientplugin)
|
||||
d->qmlclientplugin.data()->setRecording(d->profilerState->clientRecording());
|
||||
if (d->v8clientplugin)
|
||||
d->v8clientplugin.data()->setRecording(d->profilerState->clientRecording());
|
||||
}
|
||||
}
|
||||
|
||||
void QmlProfilerClientManager::serverRecordingChanged()
|
||||
{
|
||||
if (d->profilerState->serverRecording()) {
|
||||
d->v8DataReady = false;
|
||||
if (d->profilerState->serverRecording())
|
||||
d->qmlDataReady = false;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -77,7 +77,6 @@ private slots:
|
||||
void retryMessageBoxFinished(int result);
|
||||
|
||||
void qmlComplete(qint64 maximumTime);
|
||||
void v8Complete();
|
||||
|
||||
void profilerStateChanged();
|
||||
void clientRecordingChanged();
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
#include "qmlprofilermodelmanager.h"
|
||||
#include "qmlprofilerconstants.h"
|
||||
#include "qmlprofilerdatamodel.h"
|
||||
#include "qv8profilerdatamodel.h"
|
||||
#include "qmlprofilertracefile.h"
|
||||
#include "qmlprofilernotesmodel.h"
|
||||
|
||||
@@ -173,7 +172,6 @@ public:
|
||||
QmlProfilerModelManager *q;
|
||||
|
||||
QmlProfilerDataModel *model;
|
||||
QV8ProfilerDataModel *v8Model;
|
||||
QmlProfilerNotesModel *notesModel;
|
||||
|
||||
QmlProfilerDataState *dataState;
|
||||
@@ -198,7 +196,6 @@ QmlProfilerModelManager::QmlProfilerModelManager(Utils::FileInProjectFinder *fin
|
||||
d->totalWeight = 0;
|
||||
d->features = 0;
|
||||
d->model = new QmlProfilerDataModel(finder, this);
|
||||
d->v8Model = new QV8ProfilerDataModel(finder, this);
|
||||
d->dataState = new QmlProfilerDataState(this, this);
|
||||
d->traceTime = new QmlProfilerTraceTime(this);
|
||||
d->notesModel = new QmlProfilerNotesModel(this);
|
||||
@@ -220,11 +217,6 @@ QmlProfilerDataModel *QmlProfilerModelManager::qmlModel() const
|
||||
return d->model;
|
||||
}
|
||||
|
||||
QV8ProfilerDataModel *QmlProfilerModelManager::v8Model() const
|
||||
{
|
||||
return d->v8Model;
|
||||
}
|
||||
|
||||
QmlProfilerNotesModel *QmlProfilerModelManager::notesModel() const
|
||||
{
|
||||
return d->notesModel;
|
||||
@@ -232,7 +224,7 @@ QmlProfilerNotesModel *QmlProfilerModelManager::notesModel() const
|
||||
|
||||
bool QmlProfilerModelManager::isEmpty() const
|
||||
{
|
||||
return d->model->isEmpty() && d->v8Model->isEmpty();
|
||||
return d->model->isEmpty();
|
||||
}
|
||||
|
||||
int QmlProfilerModelManager::count() const
|
||||
@@ -324,12 +316,6 @@ void QmlProfilerModelManager::addQmlEvent(QmlDebug::Message message,
|
||||
ndata1, ndata2, ndata3, ndata4, ndata5);
|
||||
}
|
||||
|
||||
void QmlProfilerModelManager::addV8Event(int depth, const QString &function, const QString &filename,
|
||||
int lineNumber, double totalTime, double selfTime)
|
||||
{
|
||||
d->v8Model->addV8Event(depth, function, filename, lineNumber,totalTime, selfTime);
|
||||
}
|
||||
|
||||
void QmlProfilerModelManager::complete()
|
||||
{
|
||||
switch (state()) {
|
||||
@@ -343,7 +329,6 @@ void QmlProfilerModelManager::complete()
|
||||
d->traceTime->increaseEndTime(d->model->lastTimeMark());
|
||||
setState(QmlProfilerDataState::ProcessingData);
|
||||
d->model->complete();
|
||||
d->v8Model->complete();
|
||||
break;
|
||||
case QmlProfilerDataState::Empty:
|
||||
setState(QmlProfilerDataState::Done);
|
||||
@@ -359,7 +344,7 @@ void QmlProfilerModelManager::complete()
|
||||
void QmlProfilerModelManager::modelProcessingDone()
|
||||
{
|
||||
Q_ASSERT(state() == QmlProfilerDataState::ProcessingData);
|
||||
if (d->model->processingDone() && d->v8Model->processingDone())
|
||||
if (d->model->processingDone())
|
||||
complete();
|
||||
}
|
||||
|
||||
@@ -379,7 +364,6 @@ void QmlProfilerModelManager::save(const QString &filename)
|
||||
QmlProfilerFileWriter writer;
|
||||
writer.setTraceTime(traceTime()->startTime(), traceTime()->endTime(),
|
||||
traceTime()->duration());
|
||||
writer.setV8DataModel(d->v8Model);
|
||||
writer.setQmlEvents(d->model->getEventTypes(), d->model->getEvents());
|
||||
writer.setNotes(d->model->getEventNotes());
|
||||
writer.setFuture(&future);
|
||||
@@ -420,7 +404,6 @@ void QmlProfilerModelManager::load()
|
||||
QmlProfilerFileReader reader;
|
||||
reader.setFuture(&future);
|
||||
connect(&reader, &QmlProfilerFileReader::error, this, &QmlProfilerModelManager::error);
|
||||
reader.setV8DataModel(d->v8Model);
|
||||
reader.setQmlDataModel(d->model);
|
||||
reader.load(file);
|
||||
file->close();
|
||||
@@ -453,7 +436,6 @@ void QmlProfilerModelManager::clear()
|
||||
d->progress = 0;
|
||||
d->previousProgress = 0;
|
||||
d->model->clear();
|
||||
d->v8Model->clear();
|
||||
d->traceTime->clear();
|
||||
d->notesModel->clear();
|
||||
|
||||
|
||||
@@ -42,7 +42,6 @@
|
||||
namespace QmlProfiler {
|
||||
class QmlProfilerModelManager;
|
||||
class QmlProfilerDataModel;
|
||||
class QV8ProfilerDataModel;
|
||||
class QmlProfilerNotesModel;
|
||||
|
||||
namespace Internal {
|
||||
@@ -118,7 +117,6 @@ public:
|
||||
QmlProfilerDataState::State state() const;
|
||||
QmlProfilerTraceTime *traceTime() const;
|
||||
QmlProfilerDataModel *qmlModel() const;
|
||||
QV8ProfilerDataModel *v8Model() const;
|
||||
QmlProfilerNotesModel *notesModel() const;
|
||||
|
||||
bool isEmpty() const;
|
||||
@@ -150,8 +148,6 @@ public slots:
|
||||
qint64 startTime, qint64 length, const QString &data,
|
||||
const QmlDebug::QmlEventLocation &location,
|
||||
qint64 ndata1, qint64 ndata2, qint64 ndata3, qint64 ndata4, qint64 ndata5);
|
||||
void addV8Event(int depth, const QString &function,const QString &filename, int lineNumber,
|
||||
double totalTime, double selfTime);
|
||||
|
||||
void complete();
|
||||
void modelProcessingDone();
|
||||
|
||||
@@ -122,16 +122,10 @@ static QString qmlTypeAsString(Message message, RangeType rangeType)
|
||||
|
||||
QmlProfilerFileReader::QmlProfilerFileReader(QObject *parent) :
|
||||
QObject(parent),
|
||||
m_v8Model(0),
|
||||
m_future(0)
|
||||
{
|
||||
}
|
||||
|
||||
void QmlProfilerFileReader::setV8DataModel(QV8ProfilerDataModel *dataModel)
|
||||
{
|
||||
m_v8Model = dataModel;
|
||||
}
|
||||
|
||||
void QmlProfilerFileReader::setQmlDataModel(QmlProfilerDataModel *dataModel)
|
||||
{
|
||||
m_qmlModel = dataModel;
|
||||
@@ -190,12 +184,6 @@ bool QmlProfilerFileReader::load(QIODevice *device)
|
||||
break;
|
||||
}
|
||||
|
||||
if (elementName == _("v8profile")) {
|
||||
if (m_v8Model)
|
||||
m_v8Model->load(stream, m_future);
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
@@ -465,7 +453,6 @@ QmlProfilerFileWriter::QmlProfilerFileWriter(QObject *parent) :
|
||||
m_startTime(0),
|
||||
m_endTime(0),
|
||||
m_measuredTime(0),
|
||||
m_v8Model(0),
|
||||
m_future(0)
|
||||
{
|
||||
}
|
||||
@@ -477,11 +464,6 @@ void QmlProfilerFileWriter::setTraceTime(qint64 startTime, qint64 endTime, qint6
|
||||
m_measuredTime = measuredTime;
|
||||
}
|
||||
|
||||
void QmlProfilerFileWriter::setV8DataModel(QV8ProfilerDataModel *dataModel)
|
||||
{
|
||||
m_v8Model = dataModel;
|
||||
}
|
||||
|
||||
void QmlProfilerFileWriter::setQmlEvents(const QVector<QmlProfilerDataModel::QmlEventTypeData> &types,
|
||||
const QVector<QmlProfilerDataModel::QmlEventData> &events)
|
||||
{
|
||||
@@ -503,8 +485,7 @@ void QmlProfilerFileWriter::save(QIODevice *device)
|
||||
{
|
||||
if (m_future) {
|
||||
m_future->setProgressRange(0,
|
||||
qMax(m_qmlEvents.size() + m_ranges.size() + m_notes.size()
|
||||
+ m_v8Model->numberOfV8Events(), 1));
|
||||
qMax(m_qmlEvents.size() + m_ranges.size() + m_notes.size(), 1));
|
||||
m_future->setProgressValue(0);
|
||||
m_newProgressValue = 0;
|
||||
}
|
||||
@@ -646,7 +627,6 @@ void QmlProfilerFileWriter::save(QIODevice *device)
|
||||
|
||||
if (isCanceled())
|
||||
return;
|
||||
m_v8Model->save(stream, m_future);
|
||||
|
||||
stream.writeEndElement(); // trace
|
||||
stream.writeEndDocument();
|
||||
|
||||
@@ -40,7 +40,6 @@
|
||||
#include <qmldebug/qmlprofilereventtypes.h>
|
||||
|
||||
#include "qmlprofilerdatamodel.h"
|
||||
#include "qv8profilerdatamodel.h"
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QIODevice)
|
||||
QT_FORWARD_DECLARE_CLASS(QXmlStreamReader)
|
||||
@@ -56,7 +55,6 @@ class QmlProfilerFileReader : public QObject
|
||||
public:
|
||||
explicit QmlProfilerFileReader(QObject *parent = 0);
|
||||
|
||||
void setV8DataModel(QV8ProfilerDataModel *dataModel);
|
||||
void setQmlDataModel(QmlProfilerDataModel *dataModel);
|
||||
void setFuture(QFutureInterface<void> *future);
|
||||
|
||||
@@ -72,7 +70,6 @@ private:
|
||||
void progress(QIODevice *device);
|
||||
bool isCanceled() const;
|
||||
|
||||
QV8ProfilerDataModel *m_v8Model;
|
||||
QmlProfilerDataModel *m_qmlModel;
|
||||
QFutureInterface<void> *m_future;
|
||||
QVector<QmlProfilerDataModel::QmlEventTypeData> m_qmlEvents;
|
||||
@@ -89,7 +86,6 @@ public:
|
||||
explicit QmlProfilerFileWriter(QObject *parent = 0);
|
||||
|
||||
void setTraceTime(qint64 startTime, qint64 endTime, qint64 measturedTime);
|
||||
void setV8DataModel(QV8ProfilerDataModel *dataModel);
|
||||
void setQmlEvents(const QVector<QmlProfilerDataModel::QmlEventTypeData> &types,
|
||||
const QVector<QmlProfilerDataModel::QmlEventData> &events);
|
||||
void setNotes(const QVector<QmlProfilerDataModel::QmlEventNoteData> ¬es);
|
||||
@@ -103,7 +99,6 @@ private:
|
||||
bool isCanceled() const;
|
||||
|
||||
qint64 m_startTime, m_endTime, m_measuredTime;
|
||||
QV8ProfilerDataModel *m_v8Model;
|
||||
QFutureInterface<void> *m_future;
|
||||
QVector<QmlProfilerDataModel::QmlEventTypeData> m_qmlEvents;
|
||||
QVector<QmlProfilerDataModel::QmlEventData> m_ranges;
|
||||
|
||||
@@ -36,7 +36,6 @@
|
||||
#include "qmlprofilerstatemanager.h"
|
||||
#include "qmlprofilermodelmanager.h"
|
||||
#include "qmlprofilerstatewidget.h"
|
||||
#include "qv8profilereventview.h"
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/fancymainwindow.h>
|
||||
@@ -56,7 +55,6 @@ public:
|
||||
QDockWidget *timelineDock;
|
||||
QmlProfilerTraceView *traceView;
|
||||
QmlProfilerEventsWidget *eventsView;
|
||||
QV8ProfilerEventsWidget *v8profilerView;
|
||||
QmlProfilerStateManager *profilerState;
|
||||
QmlProfilerModelManager *profilerModelManager;
|
||||
QmlProfilerTool *profilerTool;
|
||||
@@ -71,7 +69,6 @@ QmlProfilerViewManager::QmlProfilerViewManager(QObject *parent,
|
||||
setObjectName(QLatin1String("QML Profiler View Manager"));
|
||||
d->traceView = 0;
|
||||
d->eventsView = 0;
|
||||
d->v8profilerView = 0;
|
||||
d->profilerState = profilerState;
|
||||
d->profilerModelManager = modelManager;
|
||||
d->profilerTool = profilerTool;
|
||||
@@ -109,39 +106,20 @@ void QmlProfilerViewManager::createViews()
|
||||
connect(d->eventsView, SIGNAL(typeSelected(int)), d->traceView, SLOT(selectByTypeId(int)));
|
||||
connect(d->traceView, SIGNAL(typeSelected(int)), d->eventsView, SLOT(selectByTypeId(int)));
|
||||
|
||||
d->v8profilerView = new QV8ProfilerEventsWidget(mw, d->profilerTool, this,
|
||||
d->profilerModelManager);
|
||||
d->v8profilerView->setWindowTitle(tr("V8"));
|
||||
connect(d->v8profilerView, SIGNAL(gotoSourceLocation(QString,int,int)), this,
|
||||
SIGNAL(gotoSourceLocation(QString,int,int)));
|
||||
connect(d->traceView, SIGNAL(gotoSourceLocation(QString,int,int)),
|
||||
d->v8profilerView, SLOT(selectBySourceLocation(QString,int,int)));
|
||||
connect(d->v8profilerView, SIGNAL(gotoSourceLocation(QString,int,int)),
|
||||
d->traceView, SLOT(selectBySourceLocation(QString,int,int)));
|
||||
connect(d->v8profilerView, SIGNAL(gotoSourceLocation(QString,int,int)),
|
||||
d->eventsView, SLOT(selectBySourceLocation(QString,int,int)));
|
||||
connect(d->eventsView, SIGNAL(gotoSourceLocation(QString,int,int)),
|
||||
d->v8profilerView, SLOT(selectBySourceLocation(QString,int,int)));
|
||||
|
||||
QDockWidget *eventsDock = AnalyzerManager::createDockWidget
|
||||
(QmlProfilerToolId, d->eventsView);
|
||||
d->timelineDock = AnalyzerManager::createDockWidget
|
||||
(QmlProfilerToolId, d->traceView);
|
||||
QDockWidget *v8profilerDock = AnalyzerManager::createDockWidget
|
||||
(QmlProfilerToolId, d->v8profilerView);
|
||||
|
||||
eventsDock->show();
|
||||
d->timelineDock->show();
|
||||
v8profilerDock->show();
|
||||
|
||||
mw->splitDockWidget(mw->toolBarDockWidget(), d->timelineDock, Qt::Vertical);
|
||||
mw->tabifyDockWidget(d->timelineDock, eventsDock);
|
||||
mw->tabifyDockWidget(eventsDock, v8profilerDock);
|
||||
d->timelineDock->raise();
|
||||
|
||||
new QmlProfilerStateWidget(d->profilerState, d->profilerModelManager, d->eventsView);
|
||||
new QmlProfilerStateWidget(d->profilerState, d->profilerModelManager, d->traceView);
|
||||
new QmlProfilerStateWidget(d->profilerState, d->profilerModelManager, d->v8profilerView);
|
||||
}
|
||||
|
||||
bool QmlProfilerViewManager::hasValidSelection() const
|
||||
@@ -179,7 +157,6 @@ void QmlProfilerViewManager::clear()
|
||||
{
|
||||
d->traceView->clear();
|
||||
d->eventsView->clear();
|
||||
d->v8profilerView->clear();
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -1,524 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms and
|
||||
** conditions see http://www.qt.io/terms-conditions. For further information
|
||||
** use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qv8profilerdatamodel.h"
|
||||
#include "qmlprofilermodelmanager.h"
|
||||
#include "qmlprofilerdetailsrewriter.h"
|
||||
#include "qmlprofilerbasemodel_p.h"
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QStringList>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
Q_DECLARE_TYPEINFO(QmlProfiler::QV8ProfilerDataModel::QV8EventData, Q_MOVABLE_TYPE);
|
||||
Q_DECLARE_TYPEINFO(QmlProfiler::QV8ProfilerDataModel::QV8EventSub, Q_MOVABLE_TYPE);
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace QmlProfiler {
|
||||
|
||||
typedef QHash <QString, QV8ProfilerDataModel::QV8EventSub *> EventHash;
|
||||
|
||||
static EventHash cloneEventHash(const EventHash &src)
|
||||
{
|
||||
EventHash result;
|
||||
const EventHash::ConstIterator cend = src.constEnd();
|
||||
for (EventHash::ConstIterator it = src.constBegin(); it != cend; ++it)
|
||||
result.insert(it.key(), new QV8ProfilerDataModel::QV8EventSub(it.value()));
|
||||
return result;
|
||||
}
|
||||
|
||||
QV8ProfilerDataModel::QV8EventData &QV8ProfilerDataModel::QV8EventData::operator=(const QV8EventData &ref)
|
||||
{
|
||||
if (this == &ref)
|
||||
return *this;
|
||||
|
||||
displayName = ref.displayName;
|
||||
eventHashStr = ref.eventHashStr;
|
||||
filename = ref.filename;
|
||||
functionName = ref.functionName;
|
||||
line = ref.line;
|
||||
totalTime = ref.totalTime;
|
||||
totalPercent = ref.totalPercent;
|
||||
selfTime = ref.selfTime;
|
||||
SelfTimeInPercent = ref.SelfTimeInPercent;
|
||||
typeId = ref.typeId;
|
||||
|
||||
qDeleteAll(parentHash);
|
||||
parentHash = cloneEventHash(ref.parentHash);
|
||||
|
||||
qDeleteAll(childrenHash);
|
||||
childrenHash = cloneEventHash(ref.childrenHash);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
QV8ProfilerDataModel::QV8EventData::QV8EventData()
|
||||
{
|
||||
line = -1;
|
||||
typeId = -1;
|
||||
totalTime = 0;
|
||||
selfTime = 0;
|
||||
totalPercent = 0;
|
||||
SelfTimeInPercent = 0;
|
||||
}
|
||||
|
||||
QV8ProfilerDataModel::QV8EventData::~QV8EventData()
|
||||
{
|
||||
qDeleteAll(parentHash.values());
|
||||
parentHash.clear();
|
||||
qDeleteAll(childrenHash.values());
|
||||
childrenHash.clear();
|
||||
}
|
||||
|
||||
class QV8ProfilerDataModel::QV8ProfilerDataModelPrivate :
|
||||
public QmlProfilerBaseModel::QmlProfilerBaseModelPrivate
|
||||
{
|
||||
public:
|
||||
QV8ProfilerDataModelPrivate(QV8ProfilerDataModel *qq) :
|
||||
QmlProfilerBaseModel::QmlProfilerBaseModelPrivate(qq) {}
|
||||
|
||||
QHash<QString, QV8EventData *> v8EventHash;
|
||||
QList<QV8EventData *> pendingRewrites;
|
||||
QHash<int, QV8EventData *> v8parents;
|
||||
QV8EventData v8RootEvent;
|
||||
qint64 v8MeasuredTime;
|
||||
|
||||
private:
|
||||
Q_DECLARE_PUBLIC(QV8ProfilerDataModel)
|
||||
};
|
||||
|
||||
QV8ProfilerDataModel::QV8ProfilerDataModel(Utils::FileInProjectFinder *fileFinder,
|
||||
QmlProfilerModelManager *parent)
|
||||
: QmlProfilerBaseModel(fileFinder, parent, new QV8ProfilerDataModelPrivate(this))
|
||||
{
|
||||
Q_D(QV8ProfilerDataModel);
|
||||
d->v8MeasuredTime = 0;
|
||||
clearV8RootEvent();
|
||||
}
|
||||
|
||||
void QV8ProfilerDataModel::clear()
|
||||
{
|
||||
Q_D(QV8ProfilerDataModel);
|
||||
qDeleteAll(d->v8EventHash.values());
|
||||
d->v8EventHash.clear();
|
||||
d->v8parents.clear();
|
||||
clearV8RootEvent();
|
||||
d->v8MeasuredTime = 0;
|
||||
d->pendingRewrites.clear();
|
||||
|
||||
QmlProfilerBaseModel::clear();
|
||||
}
|
||||
|
||||
bool QV8ProfilerDataModel::isEmpty() const
|
||||
{
|
||||
Q_D(const QV8ProfilerDataModel);
|
||||
return d->v8EventHash.isEmpty();
|
||||
}
|
||||
|
||||
QV8ProfilerDataModel::QV8EventData *QV8ProfilerDataModel::v8EventDescription(int typeId) const
|
||||
{
|
||||
Q_D(const QV8ProfilerDataModel);
|
||||
foreach (QV8EventData *event, d->v8EventHash) {
|
||||
if (event->typeId == typeId)
|
||||
return event;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
qint64 QV8ProfilerDataModel::v8MeasuredTime() const
|
||||
{
|
||||
Q_D(const QV8ProfilerDataModel);
|
||||
return d->v8MeasuredTime;
|
||||
}
|
||||
|
||||
QList<QV8ProfilerDataModel::QV8EventData *> QV8ProfilerDataModel::getV8Events() const
|
||||
{
|
||||
Q_D(const QV8ProfilerDataModel);
|
||||
return d->v8EventHash.values();
|
||||
}
|
||||
|
||||
int QV8ProfilerDataModel::numberOfV8Events() const
|
||||
{
|
||||
Q_D(const QV8ProfilerDataModel);
|
||||
return d->v8EventHash.size();
|
||||
}
|
||||
|
||||
QString getHashStringForV8Event(const QString &displayName, const QString &function)
|
||||
{
|
||||
return QString::fromLatin1("%1:%2").arg(displayName, function);
|
||||
}
|
||||
|
||||
void QV8ProfilerDataModel::addV8Event(int depth,
|
||||
const QString &function,
|
||||
const QString &filename,
|
||||
int lineNumber,
|
||||
double totalTime,
|
||||
double selfTime)
|
||||
{
|
||||
Q_D(QV8ProfilerDataModel);
|
||||
QString displayName = filename.mid(filename.lastIndexOf(QLatin1Char('/')) + 1) +
|
||||
QLatin1Char(':') + QString::number(lineNumber);
|
||||
QString hashStr = getHashStringForV8Event(displayName, function);
|
||||
|
||||
// time is given in milliseconds, but internally we store it in microseconds
|
||||
totalTime *= 1e6;
|
||||
selfTime *= 1e6;
|
||||
|
||||
// accumulate information
|
||||
QV8EventData *eventData = d->v8EventHash[hashStr];
|
||||
if (!eventData) {
|
||||
eventData = new QV8EventData;
|
||||
eventData->displayName = displayName;
|
||||
eventData->eventHashStr = hashStr;
|
||||
eventData->filename = filename;
|
||||
eventData->functionName = function;
|
||||
eventData->line = lineNumber;
|
||||
eventData->totalTime = totalTime;
|
||||
eventData->selfTime = selfTime;
|
||||
d->v8EventHash[hashStr] = eventData;
|
||||
} else {
|
||||
eventData->totalTime += totalTime;
|
||||
eventData->selfTime += selfTime;
|
||||
}
|
||||
d->v8parents[depth] = eventData;
|
||||
|
||||
QV8EventData *parentEvent = 0;
|
||||
if (depth == 0) {
|
||||
parentEvent = &d->v8RootEvent;
|
||||
d->v8MeasuredTime += totalTime;
|
||||
}
|
||||
if (depth > 0 && d->v8parents.contains(depth-1))
|
||||
parentEvent = d->v8parents.value(depth-1);
|
||||
|
||||
if (parentEvent != 0) {
|
||||
if (!eventData->parentHash.contains(parentEvent->eventHashStr)) {
|
||||
QV8EventSub *newParentSub = new QV8EventSub(parentEvent);
|
||||
newParentSub->totalTime = totalTime;
|
||||
|
||||
eventData->parentHash.insert(parentEvent->eventHashStr, newParentSub);
|
||||
} else {
|
||||
QV8EventSub *newParentSub = eventData->parentHash.value(parentEvent->eventHashStr);
|
||||
newParentSub->totalTime += totalTime;
|
||||
}
|
||||
|
||||
if (!parentEvent->childrenHash.contains(eventData->eventHashStr)) {
|
||||
QV8EventSub *newChildSub = new QV8EventSub(eventData);
|
||||
newChildSub->totalTime = totalTime;
|
||||
|
||||
parentEvent->childrenHash.insert(eventData->eventHashStr, newChildSub);
|
||||
} else {
|
||||
QV8EventSub *newChildSub = parentEvent->childrenHash.value(eventData->eventHashStr);
|
||||
newChildSub->totalTime += totalTime;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void QV8ProfilerDataModel::detailsChanged(int requestId, const QString &newString)
|
||||
{
|
||||
Q_D(QV8ProfilerDataModel);
|
||||
QTC_ASSERT(requestId < d->pendingRewrites.count(), return);
|
||||
d->pendingRewrites[requestId]->filename = newString;
|
||||
}
|
||||
|
||||
void QV8ProfilerDataModel::detailsDone()
|
||||
{
|
||||
Q_D(QV8ProfilerDataModel);
|
||||
d->pendingRewrites.clear();
|
||||
QmlProfilerBaseModel::detailsDone();
|
||||
}
|
||||
|
||||
void QV8ProfilerDataModel::complete()
|
||||
{
|
||||
Q_D(QV8ProfilerDataModel);
|
||||
if (!d->v8EventHash.isEmpty()) {
|
||||
double totalTimes = d->v8MeasuredTime;
|
||||
double selfTimes = 0;
|
||||
foreach (const QV8EventData *v8event, d->v8EventHash) {
|
||||
selfTimes += v8event->selfTime;
|
||||
}
|
||||
|
||||
// prevent divisions by 0
|
||||
if (totalTimes == 0)
|
||||
totalTimes = 1;
|
||||
if (selfTimes == 0)
|
||||
selfTimes = 1;
|
||||
|
||||
// insert root event in eventlist
|
||||
// the +1 ns is to get it on top of the sorted list
|
||||
d->v8RootEvent.totalTime = d->v8MeasuredTime + 1;
|
||||
d->v8RootEvent.selfTime = 0;
|
||||
|
||||
QString rootEventHash = getHashStringForV8Event(
|
||||
tr("<program>"),
|
||||
tr("Main Program"));
|
||||
QV8EventData *v8RootEventPointer = d->v8EventHash[rootEventHash];
|
||||
if (v8RootEventPointer) {
|
||||
d->v8RootEvent = *v8RootEventPointer;
|
||||
} else {
|
||||
d->v8EventHash[rootEventHash] = new QV8EventData;
|
||||
*(d->v8EventHash[rootEventHash]) = d->v8RootEvent;
|
||||
}
|
||||
|
||||
foreach (QV8EventData *v8event, d->v8EventHash) {
|
||||
v8event->totalPercent = v8event->totalTime * 100.0 / totalTimes;
|
||||
v8event->SelfTimeInPercent = v8event->selfTime * 100.0 / selfTimes;
|
||||
}
|
||||
|
||||
int index = d->pendingRewrites.size();
|
||||
foreach (QV8EventData *v8event, d->v8EventHash.values()) {
|
||||
v8event->typeId = index++;
|
||||
d->pendingRewrites << v8event;
|
||||
d->detailsRewriter->requestDetailsForLocation(index,
|
||||
QmlDebug::QmlEventLocation(v8event->filename, v8event->line, 1));
|
||||
}
|
||||
|
||||
d->v8RootEvent.typeId = d->v8EventHash[rootEventHash]->typeId;
|
||||
} else {
|
||||
// On empty data, still add a fake root event
|
||||
clearV8RootEvent();
|
||||
}
|
||||
|
||||
QmlProfilerBaseModel::complete();
|
||||
}
|
||||
|
||||
void QV8ProfilerDataModel::clearV8RootEvent()
|
||||
{
|
||||
Q_D(QV8ProfilerDataModel);
|
||||
d->v8RootEvent.displayName = tr("<program>");
|
||||
d->v8RootEvent.eventHashStr = tr("<program>");
|
||||
d->v8RootEvent.functionName = tr("Main Program");
|
||||
|
||||
d->v8RootEvent.line = -1;
|
||||
d->v8RootEvent.totalTime = 0;
|
||||
d->v8RootEvent.totalPercent = 0;
|
||||
d->v8RootEvent.selfTime = 0;
|
||||
d->v8RootEvent.SelfTimeInPercent = 0;
|
||||
d->v8RootEvent.typeId = -1;
|
||||
|
||||
qDeleteAll(d->v8RootEvent.parentHash.values());
|
||||
qDeleteAll(d->v8RootEvent.childrenHash.values());
|
||||
d->v8RootEvent.parentHash.clear();
|
||||
d->v8RootEvent.childrenHash.clear();
|
||||
}
|
||||
|
||||
void QV8ProfilerDataModel::save(QXmlStreamWriter &stream, QFutureInterface<void> *future)
|
||||
{
|
||||
Q_D(QV8ProfilerDataModel);
|
||||
stream.writeStartElement(QLatin1String("v8profile")); // v8 profiler output
|
||||
stream.writeAttribute(QLatin1String("totalTime"), QString::number(d->v8MeasuredTime));
|
||||
foreach (const QV8EventData *v8event, d->v8EventHash) {
|
||||
stream.writeStartElement(QLatin1String("event"));
|
||||
stream.writeAttribute(QLatin1String("index"),
|
||||
QString::number(
|
||||
d->v8EventHash.keys().indexOf(
|
||||
v8event->eventHashStr)));
|
||||
stream.writeTextElement(QLatin1String("displayname"), v8event->displayName);
|
||||
stream.writeTextElement(QLatin1String("functionname"), v8event->functionName);
|
||||
if (!v8event->filename.isEmpty()) {
|
||||
stream.writeTextElement(QLatin1String("filename"), v8event->filename);
|
||||
stream.writeTextElement(QLatin1String("line"), QString::number(v8event->line));
|
||||
}
|
||||
stream.writeTextElement(QLatin1String("totalTime"), QString::number(v8event->totalTime));
|
||||
stream.writeTextElement(QLatin1String("selfTime"), QString::number(v8event->selfTime));
|
||||
if (!v8event->childrenHash.isEmpty()) {
|
||||
stream.writeStartElement(QLatin1String("childrenEvents"));
|
||||
QStringList childrenIndexes;
|
||||
QStringList childrenTimes;
|
||||
QStringList parentTimes;
|
||||
foreach (const QV8EventSub *v8child, v8event->childrenHash) {
|
||||
childrenIndexes << QString::number(v8child->reference->typeId);
|
||||
childrenTimes << QString::number(v8child->totalTime);
|
||||
parentTimes << QString::number(v8child->totalTime);
|
||||
}
|
||||
|
||||
stream.writeAttribute(QLatin1String("list"), childrenIndexes.join(QLatin1String(", ")));
|
||||
stream.writeAttribute(QLatin1String("childrenTimes"), childrenTimes.join(QLatin1String(", ")));
|
||||
stream.writeAttribute(QLatin1String("parentTimes"), parentTimes.join(QLatin1String(", ")));
|
||||
stream.writeEndElement();
|
||||
}
|
||||
stream.writeEndElement();
|
||||
|
||||
if (future)
|
||||
future->setProgressValue(future->progressValue() + 1);
|
||||
}
|
||||
stream.writeEndElement(); // v8 profiler output
|
||||
}
|
||||
|
||||
void QV8ProfilerDataModel::load(QXmlStreamReader &stream, QFutureInterface<void> *future)
|
||||
{
|
||||
Q_D(QV8ProfilerDataModel);
|
||||
QHash <int, QV8EventData *> v8eventBuffer;
|
||||
QHash <int, QString> childrenIndexes;
|
||||
QHash <int, QString> childrenTimes;
|
||||
QHash <int, QString> parentTimes;
|
||||
QV8EventData *v8event = 0;
|
||||
|
||||
// time computation
|
||||
d->v8MeasuredTime = 0;
|
||||
double cumulatedV8Time = 0;
|
||||
|
||||
// get the v8 time
|
||||
QXmlStreamAttributes attributes = stream.attributes();
|
||||
if (attributes.hasAttribute(QLatin1String("totalTime")))
|
||||
d->v8MeasuredTime = attributes.value(QLatin1String("totalTime")).toString().toDouble();
|
||||
|
||||
bool finishedReading = false;
|
||||
while (!stream.atEnd() && !stream.hasError() && !finishedReading) {
|
||||
if (future && future->isCanceled())
|
||||
return;
|
||||
|
||||
QXmlStreamReader::TokenType token = stream.readNext();
|
||||
const QStringRef elementName = stream.name();
|
||||
switch (token) {
|
||||
case QXmlStreamReader::StartDocument : continue;
|
||||
case QXmlStreamReader::StartElement : {
|
||||
if (elementName == QLatin1String("event")) {
|
||||
if (future)
|
||||
future->setProgressValue(qMin(stream.device()->pos(), qint64(INT_MAX)));
|
||||
QXmlStreamAttributes attributes = stream.attributes();
|
||||
if (attributes.hasAttribute(QLatin1String("index"))) {
|
||||
int ndx = attributes.value(QLatin1String("index")).toString().toInt();
|
||||
if (!v8eventBuffer.value(ndx))
|
||||
v8eventBuffer[ndx] = new QV8EventData;
|
||||
v8event = v8eventBuffer[ndx];
|
||||
} else {
|
||||
v8event = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (!v8event)
|
||||
break;
|
||||
|
||||
if (elementName == QLatin1String("childrenEvents")) {
|
||||
QXmlStreamAttributes attributes = stream.attributes();
|
||||
int eventIndex = v8eventBuffer.key(v8event);
|
||||
if (attributes.hasAttribute(QLatin1String("list"))) {
|
||||
// store for later parsing (we haven't read all the events yet)
|
||||
childrenIndexes[eventIndex] = attributes.value(QLatin1String("list")).toString();
|
||||
}
|
||||
if (attributes.hasAttribute(QLatin1String("childrenTimes"))) {
|
||||
childrenTimes[eventIndex] =
|
||||
attributes.value(QLatin1String("childrenTimes")).toString();
|
||||
}
|
||||
if (attributes.hasAttribute(QLatin1String("parentTimes")))
|
||||
parentTimes[eventIndex] = attributes.value(QLatin1String("parentTimes")).toString();
|
||||
}
|
||||
|
||||
stream.readNext();
|
||||
if (stream.tokenType() != QXmlStreamReader::Characters)
|
||||
break;
|
||||
QString readData = stream.text().toString();
|
||||
|
||||
if (elementName == QLatin1String("displayname")) {
|
||||
v8event->displayName = readData;
|
||||
break;
|
||||
}
|
||||
|
||||
if (elementName == QLatin1String("functionname")) {
|
||||
v8event->functionName = readData;
|
||||
break;
|
||||
}
|
||||
|
||||
if (elementName == QLatin1String("filename")) {
|
||||
v8event->filename = readData;
|
||||
break;
|
||||
}
|
||||
|
||||
if (elementName == QLatin1String("line")) {
|
||||
v8event->line = readData.toInt();
|
||||
break;
|
||||
}
|
||||
|
||||
if (elementName == QLatin1String("totalTime")) {
|
||||
v8event->totalTime = readData.toDouble();
|
||||
cumulatedV8Time += v8event->totalTime;
|
||||
break;
|
||||
}
|
||||
|
||||
if (elementName == QLatin1String("selfTime")) {
|
||||
v8event->selfTime = readData.toDouble();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case QXmlStreamReader::EndElement : {
|
||||
if (elementName == QLatin1String("v8profile")) {
|
||||
finishedReading = true;
|
||||
// done reading the v8 profile data
|
||||
break;
|
||||
}
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
// backwards compatibility
|
||||
if (d->v8MeasuredTime == 0)
|
||||
d->v8MeasuredTime = cumulatedV8Time;
|
||||
|
||||
// find v8events' children and parents
|
||||
typedef QHash <int, QString>::ConstIterator ChildIndexConstIt;
|
||||
|
||||
const ChildIndexConstIt icend = childrenIndexes.constEnd();
|
||||
for (ChildIndexConstIt it = childrenIndexes.constBegin(); it != icend; ++it) {
|
||||
const int parentIndex = it.key();
|
||||
const QStringList childrenStrings = it.value().split(QLatin1Char(','));
|
||||
QStringList childrenTimesStrings = childrenTimes.value(parentIndex).split(QLatin1String(", "));
|
||||
QStringList parentTimesStrings = parentTimes.value(parentIndex).split(QLatin1String(", "));
|
||||
for (int ndx = 0; ndx < childrenStrings.count(); ndx++) {
|
||||
int childIndex = childrenStrings[ndx].toInt();
|
||||
if (v8eventBuffer.value(childIndex)) {
|
||||
QV8EventSub *newChild = new QV8EventSub(v8eventBuffer[childIndex]);
|
||||
QV8EventSub *newParent = new QV8EventSub(v8eventBuffer[parentIndex]);
|
||||
if (childrenTimesStrings.count() > ndx)
|
||||
newChild->totalTime = childrenTimesStrings[ndx].toDouble();
|
||||
if (parentTimesStrings.count() > ndx)
|
||||
newParent->totalTime = parentTimesStrings[ndx].toDouble();
|
||||
v8eventBuffer[parentIndex]->childrenHash.insert(
|
||||
newChild->reference->displayName,
|
||||
newChild);
|
||||
v8eventBuffer[childIndex]->parentHash.insert(
|
||||
newParent->reference->displayName,
|
||||
newParent);
|
||||
}
|
||||
}
|
||||
}
|
||||
// store v8 events
|
||||
foreach (QV8EventData *storedV8Event, v8eventBuffer) {
|
||||
storedV8Event->eventHashStr =
|
||||
getHashStringForV8Event(
|
||||
storedV8Event->displayName, storedV8Event->functionName);
|
||||
d->v8EventHash[storedV8Event->eventHashStr] = storedV8Event;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace QmlProfiler
|
||||
@@ -1,115 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms and
|
||||
** conditions see http://www.qt.io/terms-conditions. For further information
|
||||
** use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QV8PROFILERDATAMODEL_H
|
||||
#define QV8PROFILERDATAMODEL_H
|
||||
|
||||
#include "qmlprofilerbasemodel.h"
|
||||
#include <utils/fileinprojectfinder.h>
|
||||
|
||||
#include <QFutureInterface>
|
||||
#include <QObject>
|
||||
#include <QHash>
|
||||
|
||||
#include <QXmlStreamReader>
|
||||
#include <QXmlStreamWriter>
|
||||
|
||||
namespace QmlProfiler {
|
||||
|
||||
class QV8ProfilerDataModel : public QmlProfilerBaseModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
struct QV8EventSub;
|
||||
|
||||
struct QV8EventData
|
||||
{
|
||||
QV8EventData();
|
||||
~QV8EventData();
|
||||
|
||||
QString displayName;
|
||||
QString eventHashStr;
|
||||
QString filename;
|
||||
QString functionName;
|
||||
int line;
|
||||
double totalTime; // given in milliseconds
|
||||
double totalPercent;
|
||||
double selfTime;
|
||||
double SelfTimeInPercent;
|
||||
QHash <QString, QV8EventSub *> parentHash;
|
||||
QHash <QString, QV8EventSub *> childrenHash;
|
||||
int typeId;
|
||||
|
||||
QV8EventData &operator=(const QV8EventData &ref);
|
||||
};
|
||||
|
||||
struct QV8EventSub {
|
||||
QV8EventSub(QV8EventData *from) : reference(from), totalTime(0) {}
|
||||
QV8EventSub(QV8EventSub *from) : reference(from->reference), totalTime(from->totalTime) {}
|
||||
|
||||
QV8EventData *reference;
|
||||
qint64 totalTime;
|
||||
};
|
||||
|
||||
QV8ProfilerDataModel(Utils::FileInProjectFinder *fileFinder, QmlProfilerModelManager *parent = 0);
|
||||
|
||||
void clear();
|
||||
bool isEmpty() const;
|
||||
QList<QV8EventData *> getV8Events() const;
|
||||
int numberOfV8Events() const;
|
||||
QV8EventData *v8EventDescription(int typeId) const;
|
||||
|
||||
qint64 v8MeasuredTime() const;
|
||||
|
||||
void save(QXmlStreamWriter &stream, QFutureInterface<void> *future = 0);
|
||||
void load(QXmlStreamReader &stream, QFutureInterface<void> *future = 0);
|
||||
|
||||
void complete();
|
||||
|
||||
public slots:
|
||||
void addV8Event(int depth,
|
||||
const QString &function,
|
||||
const QString &filename,
|
||||
int lineNumber,
|
||||
double totalTime,
|
||||
double selfTime);
|
||||
void detailsChanged(int requestId, const QString &newString);
|
||||
void detailsDone();
|
||||
|
||||
private:
|
||||
class QV8ProfilerDataModelPrivate;
|
||||
void clearV8RootEvent();
|
||||
|
||||
Q_DECLARE_PRIVATE(QV8ProfilerDataModel)
|
||||
};
|
||||
|
||||
} // namespace QmlProfiler
|
||||
|
||||
#endif // QV8PROFILERDATAMODEL_H
|
||||
@@ -1,717 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms and
|
||||
** conditions see http://www.qt.io/terms-conditions. For further information
|
||||
** use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qv8profilereventview.h"
|
||||
|
||||
#include <QUrl>
|
||||
#include <QHash>
|
||||
|
||||
#include <QStandardItem>
|
||||
#include <QHeaderView>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QClipboard>
|
||||
|
||||
#include <QContextMenuEvent>
|
||||
#include <QDebug>
|
||||
|
||||
#include <coreplugin/minisplitter.h>
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
|
||||
#include "qmlprofilerviewmanager.h"
|
||||
#include "qmlprofilertool.h"
|
||||
#include "qv8profilerdatamodel.h"
|
||||
#include <QMenu>
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
using namespace QmlDebug;
|
||||
|
||||
namespace QmlProfiler {
|
||||
namespace Internal {
|
||||
|
||||
enum ItemRole {
|
||||
SortRole = Qt::UserRole + 1, // Sort by data, not by displayed text
|
||||
FilenameRole,
|
||||
LineRole,
|
||||
TypeIdRole
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class V8ViewItem : public QStandardItem
|
||||
{
|
||||
public:
|
||||
V8ViewItem(const QString &text) : QStandardItem(text) {}
|
||||
|
||||
virtual bool operator<(const QStandardItem &other) const
|
||||
{
|
||||
// first column is special
|
||||
if (column() == 0) {
|
||||
int filenameDiff = QUrl(data(FilenameRole).toString()).fileName().compare(
|
||||
QUrl(other.data(FilenameRole).toString()).fileName(), Qt::CaseInsensitive);
|
||||
return filenameDiff != 0 ? filenameDiff < 0 :
|
||||
data(LineRole).toInt() < other.data(LineRole).toInt();
|
||||
} else if (data(SortRole).type() == QVariant::String) {
|
||||
// Strings should be case-insensitive compared
|
||||
return data(SortRole).toString().compare(other.data(SortRole).toString(),
|
||||
Qt::CaseInsensitive) < 0;
|
||||
} else {
|
||||
// For everything else the standard comparison should be OK
|
||||
return QStandardItem::operator<(other);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class QV8ProfilerEventsWidget::QV8ProfilerEventsWidgetPrivate
|
||||
{
|
||||
public:
|
||||
QV8ProfilerEventsWidgetPrivate(QV8ProfilerEventsWidget *qq):q(qq) {}
|
||||
~QV8ProfilerEventsWidgetPrivate() {}
|
||||
|
||||
QV8ProfilerEventsWidget *q;
|
||||
|
||||
QmlProfilerTool *m_profilerTool;
|
||||
QmlProfilerViewManager *m_viewContainer;
|
||||
|
||||
QV8ProfilerEventsMainView *m_eventTree;
|
||||
QV8ProfilerEventRelativesView *m_eventChildren;
|
||||
QV8ProfilerEventRelativesView *m_eventParents;
|
||||
|
||||
QV8ProfilerDataModel *v8Model;
|
||||
};
|
||||
|
||||
QV8ProfilerEventsWidget::QV8ProfilerEventsWidget(QWidget *parent,
|
||||
QmlProfilerTool *profilerTool,
|
||||
QmlProfilerViewManager *container,
|
||||
QmlProfilerModelManager *profilerModelManager )
|
||||
: QWidget(parent), d(new QV8ProfilerEventsWidgetPrivate(this))
|
||||
{
|
||||
setObjectName(QLatin1String("QmlProfilerV8ProfileView"));
|
||||
|
||||
d->v8Model = profilerModelManager->v8Model();
|
||||
|
||||
d->m_eventTree = new QV8ProfilerEventsMainView(this, d->v8Model);
|
||||
connect(d->m_eventTree, SIGNAL(gotoSourceLocation(QString,int,int)), this, SIGNAL(gotoSourceLocation(QString,int,int)));
|
||||
|
||||
d->m_eventChildren = new QV8ProfilerEventRelativesView(d->v8Model,
|
||||
QV8ProfilerEventRelativesView::ChildrenView,
|
||||
this);
|
||||
d->m_eventParents = new QV8ProfilerEventRelativesView(d->v8Model,
|
||||
QV8ProfilerEventRelativesView::ParentsView,
|
||||
this);
|
||||
connect(d->m_eventTree, SIGNAL(typeSelected(int)), d->m_eventChildren, SLOT(displayType(int)));
|
||||
connect(d->m_eventTree, SIGNAL(typeSelected(int)), d->m_eventParents, SLOT(displayType(int)));
|
||||
connect(d->m_eventChildren, SIGNAL(typeClicked(int)), d->m_eventTree, SLOT(selectType(int)));
|
||||
connect(d->m_eventParents, SIGNAL(typeClicked(int)), d->m_eventTree, SLOT(selectType(int)));
|
||||
connect(d->v8Model, SIGNAL(changed()), this, SLOT(updateEnabledState()));
|
||||
|
||||
// widget arrangement
|
||||
QVBoxLayout *groupLayout = new QVBoxLayout;
|
||||
groupLayout->setContentsMargins(0,0,0,0);
|
||||
groupLayout->setSpacing(0);
|
||||
|
||||
Core::MiniSplitter *splitterVertical = new Core::MiniSplitter;
|
||||
splitterVertical->addWidget(d->m_eventTree);
|
||||
Core::MiniSplitter *splitterHorizontal = new Core::MiniSplitter;
|
||||
splitterHorizontal->addWidget(d->m_eventParents);
|
||||
splitterHorizontal->addWidget(d->m_eventChildren);
|
||||
splitterHorizontal->setOrientation(Qt::Horizontal);
|
||||
splitterVertical->addWidget(splitterHorizontal);
|
||||
splitterVertical->setOrientation(Qt::Vertical);
|
||||
splitterVertical->setStretchFactor(0,5);
|
||||
splitterVertical->setStretchFactor(1,2);
|
||||
groupLayout->addWidget(splitterVertical);
|
||||
setLayout(groupLayout);
|
||||
|
||||
d->m_profilerTool = profilerTool;
|
||||
d->m_viewContainer = container;
|
||||
setEnabled(false);
|
||||
}
|
||||
|
||||
QV8ProfilerEventsWidget::~QV8ProfilerEventsWidget()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
void QV8ProfilerEventsWidget::updateEnabledState()
|
||||
{
|
||||
setEnabled(!d->v8Model->isEmpty());
|
||||
}
|
||||
|
||||
void QV8ProfilerEventsWidget::clear()
|
||||
{
|
||||
d->m_eventTree->clear();
|
||||
d->m_eventChildren->clear();
|
||||
d->m_eventParents->clear();
|
||||
setEnabled(false);
|
||||
}
|
||||
|
||||
QModelIndex QV8ProfilerEventsWidget::selectedItem() const
|
||||
{
|
||||
return d->m_eventTree->selectedItem();
|
||||
}
|
||||
|
||||
void QV8ProfilerEventsWidget::contextMenuEvent(QContextMenuEvent *ev)
|
||||
{
|
||||
QTC_ASSERT(d->m_viewContainer, return;);
|
||||
|
||||
QMenu menu;
|
||||
QAction *copyRowAction = 0;
|
||||
QAction *copyTableAction = 0;
|
||||
|
||||
QmlProfilerTool *profilerTool = qobject_cast<QmlProfilerTool *>(d->m_profilerTool);
|
||||
QPoint position = ev->globalPos();
|
||||
|
||||
if (profilerTool) {
|
||||
QList <QAction *> commonActions = profilerTool->profilerContextMenuActions();
|
||||
foreach (QAction *act, commonActions) {
|
||||
menu.addAction(act);
|
||||
}
|
||||
}
|
||||
|
||||
if (mouseOnTable(position)) {
|
||||
menu.addSeparator();
|
||||
if (selectedItem().isValid())
|
||||
copyRowAction = menu.addAction(QCoreApplication::translate("QmlProfiler::Internal::QmlProfilerEventsWidget", "Copy Row"));
|
||||
copyTableAction = menu.addAction(QCoreApplication::translate("QmlProfiler::Internal::QmlProfilerEventsWidget", "Copy Table"));
|
||||
}
|
||||
|
||||
QAction *selectedAction = menu.exec(position);
|
||||
|
||||
if (selectedAction) {
|
||||
if (selectedAction == copyRowAction)
|
||||
copyRowToClipboard();
|
||||
if (selectedAction == copyTableAction)
|
||||
copyTableToClipboard();
|
||||
}
|
||||
}
|
||||
|
||||
void QV8ProfilerEventsWidget::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
QWidget::resizeEvent(event);
|
||||
emit resized();
|
||||
}
|
||||
|
||||
bool QV8ProfilerEventsWidget::mouseOnTable(const QPoint &position) const
|
||||
{
|
||||
QPoint tableTopLeft = d->m_eventTree->mapToGlobal(QPoint(0,0));
|
||||
QPoint tableBottomRight = d->m_eventTree->mapToGlobal(QPoint(d->m_eventTree->width(), d->m_eventTree->height()));
|
||||
return (position.x() >= tableTopLeft.x() && position.x() <= tableBottomRight.x() && position.y() >= tableTopLeft.y() && position.y() <= tableBottomRight.y());
|
||||
}
|
||||
|
||||
void QV8ProfilerEventsWidget::copyTableToClipboard() const
|
||||
{
|
||||
d->m_eventTree->copyTableToClipboard();
|
||||
}
|
||||
|
||||
void QV8ProfilerEventsWidget::copyRowToClipboard() const
|
||||
{
|
||||
d->m_eventTree->copyRowToClipboard();
|
||||
}
|
||||
|
||||
void QV8ProfilerEventsWidget::updateSelectedType(int typeId) const
|
||||
{
|
||||
if (d->m_eventTree->selectedTypeId() != typeId)
|
||||
d->m_eventTree->selectType(typeId);
|
||||
}
|
||||
|
||||
void QV8ProfilerEventsWidget::selectBySourceLocation(const QString &filename, int line, int column)
|
||||
{
|
||||
// This slot is used to connect the javascript pane with the qml events pane
|
||||
// Our javascript trace data does not store column information
|
||||
// thus we ignore it here
|
||||
Q_UNUSED(column);
|
||||
d->m_eventTree->selectEventByLocation(filename, line);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class QV8ProfilerEventsMainView::QV8ProfilerEventsMainViewPrivate
|
||||
{
|
||||
public:
|
||||
QV8ProfilerEventsMainViewPrivate(QV8ProfilerEventsMainView *qq) : q(qq) {}
|
||||
|
||||
void buildV8ModelFromList( const QList<QV8ProfilerDataModel::QV8EventData *> &list );
|
||||
int getFieldCount();
|
||||
|
||||
QString textForItem(QStandardItem *item, bool recursive) const;
|
||||
|
||||
|
||||
QV8ProfilerEventsMainView *q;
|
||||
|
||||
QV8ProfilerDataModel *m_v8Model;
|
||||
QStandardItemModel *m_model;
|
||||
QList<bool> m_fieldShown;
|
||||
QHash<int, int> m_columnIndex; // maps field enum to column index
|
||||
int m_firstNumericColumn;
|
||||
bool m_preventSelectBounce;
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
QV8ProfilerEventsMainView::QV8ProfilerEventsMainView(QWidget *parent,
|
||||
QV8ProfilerDataModel *v8Model)
|
||||
: QmlProfilerTreeView(parent), d(new QV8ProfilerEventsMainViewPrivate(this))
|
||||
{
|
||||
setObjectName(QLatin1String("QmlProfilerEventsTable"));
|
||||
setSortingEnabled(false);
|
||||
|
||||
d->m_model = new QStandardItemModel(this);
|
||||
d->m_model->setSortRole(SortRole);
|
||||
setModel(d->m_model);
|
||||
connect(this, SIGNAL(activated(QModelIndex)), this, SLOT(jumpToItem(QModelIndex)));
|
||||
|
||||
d->m_v8Model = v8Model;
|
||||
connect(d->m_v8Model, SIGNAL(changed()), this, SLOT(buildModel()));
|
||||
d->m_firstNumericColumn = 0;
|
||||
d->m_preventSelectBounce = false;
|
||||
|
||||
setFieldViewable(Name, true);
|
||||
setFieldViewable(Type, false);
|
||||
setFieldViewable(TimeInPercent, true);
|
||||
setFieldViewable(TotalTime, true);
|
||||
setFieldViewable(SelfTimeInPercent, true);
|
||||
setFieldViewable(SelfTime, true);
|
||||
setFieldViewable(CallCount, false);
|
||||
setFieldViewable(TimePerCall, false);
|
||||
setFieldViewable(MaxTime, false);
|
||||
setFieldViewable(MinTime, false);
|
||||
setFieldViewable(MedianTime, false);
|
||||
setFieldViewable(Details, true);
|
||||
|
||||
buildModel();
|
||||
}
|
||||
|
||||
QV8ProfilerEventsMainView::~QV8ProfilerEventsMainView()
|
||||
{
|
||||
clear();
|
||||
delete d->m_model;
|
||||
delete d;
|
||||
}
|
||||
|
||||
void QV8ProfilerEventsMainView::setFieldViewable(Fields field, bool show)
|
||||
{
|
||||
if (field < MaxFields) {
|
||||
int length = d->m_fieldShown.count();
|
||||
if (field >= length) {
|
||||
for (int i=length; i<MaxFields; i++)
|
||||
d->m_fieldShown << false;
|
||||
}
|
||||
d->m_fieldShown[field] = show;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void QV8ProfilerEventsMainView::setHeaderLabels()
|
||||
{
|
||||
int fieldIndex = 0;
|
||||
d->m_firstNumericColumn = 0;
|
||||
|
||||
d->m_columnIndex.clear();
|
||||
if (d->m_fieldShown[Name]) {
|
||||
d->m_columnIndex[Name] = fieldIndex;
|
||||
d->m_model->setHeaderData(fieldIndex++, Qt::Horizontal, QVariant(displayHeader(Location)));
|
||||
d->m_firstNumericColumn++;
|
||||
}
|
||||
if (d->m_fieldShown[Type]) {
|
||||
d->m_columnIndex[Type] = fieldIndex;
|
||||
d->m_model->setHeaderData(fieldIndex++, Qt::Horizontal, QVariant(displayHeader(Type)));
|
||||
d->m_firstNumericColumn++;
|
||||
}
|
||||
if (d->m_fieldShown[TimeInPercent]) {
|
||||
d->m_columnIndex[TimeInPercent] = fieldIndex;
|
||||
d->m_model->setHeaderData(fieldIndex++, Qt::Horizontal, QVariant(displayHeader(TimeInPercent)));
|
||||
}
|
||||
if (d->m_fieldShown[TotalTime]) {
|
||||
d->m_columnIndex[TotalTime] = fieldIndex;
|
||||
d->m_model->setHeaderData(fieldIndex++, Qt::Horizontal, QVariant(displayHeader(TotalTime)));
|
||||
}
|
||||
if (d->m_fieldShown[SelfTimeInPercent]) {
|
||||
d->m_columnIndex[Type] = fieldIndex;
|
||||
d->m_model->setHeaderData(fieldIndex++, Qt::Horizontal, QVariant(displayHeader(SelfTimeInPercent)));
|
||||
}
|
||||
if (d->m_fieldShown[SelfTime]) {
|
||||
d->m_columnIndex[SelfTime] = fieldIndex;
|
||||
d->m_model->setHeaderData(fieldIndex++, Qt::Horizontal, QVariant(displayHeader(SelfTime)));
|
||||
}
|
||||
if (d->m_fieldShown[CallCount]) {
|
||||
d->m_columnIndex[CallCount] = fieldIndex;
|
||||
d->m_model->setHeaderData(fieldIndex++, Qt::Horizontal, QVariant(displayHeader(CallCount)));
|
||||
}
|
||||
if (d->m_fieldShown[TimePerCall]) {
|
||||
d->m_columnIndex[TimePerCall] = fieldIndex;
|
||||
d->m_model->setHeaderData(fieldIndex++, Qt::Horizontal, QVariant(displayHeader(TimePerCall)));
|
||||
}
|
||||
if (d->m_fieldShown[MedianTime]) {
|
||||
d->m_columnIndex[MedianTime] = fieldIndex;
|
||||
d->m_model->setHeaderData(fieldIndex++, Qt::Horizontal, QVariant(displayHeader(MedianTime)));
|
||||
}
|
||||
if (d->m_fieldShown[MaxTime]) {
|
||||
d->m_columnIndex[MaxTime] = fieldIndex;
|
||||
d->m_model->setHeaderData(fieldIndex++, Qt::Horizontal, QVariant(displayHeader(MaxTime)));
|
||||
}
|
||||
if (d->m_fieldShown[MinTime]) {
|
||||
d->m_columnIndex[MinTime] = fieldIndex;
|
||||
d->m_model->setHeaderData(fieldIndex++, Qt::Horizontal, QVariant(displayHeader(MinTime)));
|
||||
}
|
||||
if (d->m_fieldShown[Details]) {
|
||||
d->m_columnIndex[Details] = fieldIndex;
|
||||
d->m_model->setHeaderData(fieldIndex++, Qt::Horizontal, QVariant(displayHeader(Details)));
|
||||
}
|
||||
}
|
||||
|
||||
void QV8ProfilerEventsMainView::clear()
|
||||
{
|
||||
d->m_model->clear();
|
||||
d->m_model->setColumnCount(d->getFieldCount());
|
||||
|
||||
setHeaderLabels();
|
||||
setSortingEnabled(false);
|
||||
}
|
||||
|
||||
int QV8ProfilerEventsMainView::QV8ProfilerEventsMainViewPrivate::getFieldCount()
|
||||
{
|
||||
int count = 0;
|
||||
for (int i=0; i < m_fieldShown.count(); ++i)
|
||||
if (m_fieldShown[i])
|
||||
count++;
|
||||
return count;
|
||||
}
|
||||
|
||||
void QV8ProfilerEventsMainView::buildModel()
|
||||
{
|
||||
clear();
|
||||
d->buildV8ModelFromList( d->m_v8Model->getV8Events() );
|
||||
|
||||
setRootIsDecorated(false);
|
||||
setSortingEnabled(true);
|
||||
sortByColumn(d->m_firstNumericColumn,Qt::DescendingOrder);
|
||||
|
||||
expandAll();
|
||||
if (d->m_fieldShown[Name])
|
||||
resizeColumnToContents(0);
|
||||
|
||||
if (d->m_fieldShown[Type])
|
||||
resizeColumnToContents(d->m_fieldShown[Name]?1:0);
|
||||
collapseAll();
|
||||
}
|
||||
|
||||
void QV8ProfilerEventsMainView::QV8ProfilerEventsMainViewPrivate::buildV8ModelFromList(
|
||||
const QList<QV8ProfilerDataModel::QV8EventData *> &list)
|
||||
{
|
||||
for (int index = 0; index < list.count(); index++) {
|
||||
QV8ProfilerDataModel::QV8EventData *v8event = list.at(index);
|
||||
QList<QStandardItem *> newRow;
|
||||
|
||||
if (m_fieldShown[Name])
|
||||
newRow << new V8ViewItem(v8event->displayName);
|
||||
|
||||
if (m_fieldShown[TimeInPercent]) {
|
||||
newRow << new V8ViewItem(QString::number(v8event->totalPercent,'f',2)+QLatin1String(" %"));
|
||||
newRow.last()->setData(QVariant(v8event->totalPercent));
|
||||
}
|
||||
|
||||
if (m_fieldShown[TotalTime]) {
|
||||
newRow << new V8ViewItem(QmlProfilerBaseModel::formatTime(v8event->totalTime));
|
||||
newRow.last()->setData(QVariant(v8event->totalTime));
|
||||
}
|
||||
|
||||
if (m_fieldShown[SelfTimeInPercent]) {
|
||||
newRow << new V8ViewItem(QString::number(v8event->SelfTimeInPercent,'f',2)+QLatin1String(" %"));
|
||||
newRow.last()->setData(QVariant(v8event->SelfTimeInPercent));
|
||||
}
|
||||
|
||||
if (m_fieldShown[SelfTime]) {
|
||||
newRow << new V8ViewItem(QmlProfilerBaseModel::formatTime(v8event->selfTime));
|
||||
newRow.last()->setData(QVariant(v8event->selfTime));
|
||||
}
|
||||
|
||||
if (m_fieldShown[Details]) {
|
||||
newRow << new V8ViewItem(v8event->functionName);
|
||||
newRow.last()->setData(QVariant(v8event->functionName));
|
||||
}
|
||||
|
||||
if (!newRow.isEmpty()) {
|
||||
// no edit
|
||||
foreach (QStandardItem *item, newRow)
|
||||
item->setEditable(false);
|
||||
|
||||
// metadata
|
||||
QStandardItem *firstItem = newRow.at(0);
|
||||
firstItem->setData(QVariant(v8event->filename), FilenameRole);
|
||||
firstItem->setData(QVariant(v8event->line), LineRole);
|
||||
firstItem->setData(QVariant(v8event->typeId), TypeIdRole);
|
||||
|
||||
// append
|
||||
m_model->invisibleRootItem()->appendRow(newRow);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int QV8ProfilerEventsMainView::selectedTypeId() const
|
||||
{
|
||||
QModelIndex index = selectedItem();
|
||||
if (!index.isValid())
|
||||
return -1;
|
||||
QStandardItem *item = d->m_model->item(index.row(), 0);
|
||||
return item->data(TypeIdRole).toInt();
|
||||
}
|
||||
|
||||
void QV8ProfilerEventsMainView::jumpToItem(const QModelIndex &index)
|
||||
{
|
||||
if (d->m_preventSelectBounce)
|
||||
return;
|
||||
|
||||
d->m_preventSelectBounce = true;
|
||||
QStandardItem *clickedItem = d->m_model->itemFromIndex(index);
|
||||
QStandardItem *infoItem;
|
||||
if (clickedItem->parent())
|
||||
infoItem = clickedItem->parent()->child(clickedItem->row(), 0);
|
||||
else
|
||||
infoItem = d->m_model->item(index.row(), 0);
|
||||
|
||||
// show in editor
|
||||
int line = infoItem->data(LineRole).toInt();
|
||||
QString fileName = infoItem->data(FilenameRole).toString();
|
||||
if (line!=-1 && !fileName.isEmpty())
|
||||
emit gotoSourceLocation(fileName, line, -1);
|
||||
|
||||
// show in callers/callees subwindow
|
||||
emit typeSelected(infoItem->data(TypeIdRole).toInt());
|
||||
|
||||
d->m_preventSelectBounce = false;
|
||||
}
|
||||
|
||||
void QV8ProfilerEventsMainView::selectType(int typeId)
|
||||
{
|
||||
for (int i=0; i<d->m_model->rowCount(); i++) {
|
||||
QStandardItem *infoItem = d->m_model->item(i, 0);
|
||||
if (infoItem->data(TypeIdRole).toInt() == typeId) {
|
||||
setCurrentIndex(d->m_model->indexFromItem(infoItem));
|
||||
jumpToItem(currentIndex());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QV8ProfilerEventsMainView::selectEventByLocation(const QString &filename, int line)
|
||||
{
|
||||
if (d->m_preventSelectBounce)
|
||||
return;
|
||||
|
||||
for (int i=0; i<d->m_model->rowCount(); i++) {
|
||||
QStandardItem *infoItem = d->m_model->item(i, 0);
|
||||
if (currentIndex() != d->m_model->indexFromItem(infoItem) &&
|
||||
infoItem->data(FilenameRole).toString() == filename &&
|
||||
infoItem->data(LineRole).toInt() == line) {
|
||||
setCurrentIndex(d->m_model->indexFromItem(infoItem));
|
||||
jumpToItem(currentIndex());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QModelIndex QV8ProfilerEventsMainView::selectedItem() const
|
||||
{
|
||||
QModelIndexList sel = selectedIndexes();
|
||||
if (sel.isEmpty())
|
||||
return QModelIndex();
|
||||
else
|
||||
return sel.first();
|
||||
}
|
||||
|
||||
QString QV8ProfilerEventsMainView::QV8ProfilerEventsMainViewPrivate::textForItem(QStandardItem *item, bool recursive = true) const
|
||||
{
|
||||
QString str;
|
||||
|
||||
if (recursive) {
|
||||
// indentation
|
||||
QStandardItem *itemParent = item->parent();
|
||||
while (itemParent) {
|
||||
str += QLatin1String(" ");
|
||||
itemParent = itemParent->parent();
|
||||
}
|
||||
}
|
||||
|
||||
// item's data
|
||||
int colCount = m_model->columnCount();
|
||||
for (int j = 0; j < colCount; ++j) {
|
||||
QStandardItem *colItem = item->parent() ? item->parent()->child(item->row(),j) : m_model->item(item->row(),j);
|
||||
str += colItem->data(Qt::DisplayRole).toString();
|
||||
if (j < colCount-1) str += QLatin1Char('\t');
|
||||
}
|
||||
str += QLatin1Char('\n');
|
||||
|
||||
// recursively print children
|
||||
if (recursive && item->child(0))
|
||||
for (int j = 0; j != item->rowCount(); j++)
|
||||
str += textForItem(item->child(j));
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
void QV8ProfilerEventsMainView::copyTableToClipboard() const
|
||||
{
|
||||
QString str;
|
||||
// headers
|
||||
int columnCount = d->m_model->columnCount();
|
||||
for (int i = 0; i < columnCount; ++i) {
|
||||
str += d->m_model->headerData(i, Qt::Horizontal, Qt::DisplayRole).toString();
|
||||
if (i < columnCount - 1)
|
||||
str += QLatin1Char('\t');
|
||||
else
|
||||
str += QLatin1Char('\n');
|
||||
}
|
||||
// data
|
||||
int rowCount = d->m_model->rowCount();
|
||||
for (int i = 0; i != rowCount; ++i) {
|
||||
str += d->textForItem(d->m_model->item(i));
|
||||
}
|
||||
QClipboard *clipboard = QApplication::clipboard();
|
||||
clipboard->setText(str, QClipboard::Selection);
|
||||
clipboard->setText(str, QClipboard::Clipboard);
|
||||
}
|
||||
|
||||
void QV8ProfilerEventsMainView::copyRowToClipboard() const
|
||||
{
|
||||
QString str;
|
||||
str = d->textForItem(d->m_model->itemFromIndex(selectedItem()), false);
|
||||
|
||||
QClipboard *clipboard = QApplication::clipboard();
|
||||
clipboard->setText(str, QClipboard::Selection);
|
||||
clipboard->setText(str, QClipboard::Clipboard);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
QV8ProfilerEventRelativesView::QV8ProfilerEventRelativesView(QV8ProfilerDataModel *model,
|
||||
SubViewType viewType,
|
||||
QWidget *parent)
|
||||
: QmlProfilerTreeView(parent)
|
||||
, m_type(viewType)
|
||||
, m_v8Model(model)
|
||||
, m_model(new QStandardItemModel(this))
|
||||
{
|
||||
m_model->setSortRole(SortRole);
|
||||
setModel(m_model);
|
||||
|
||||
updateHeader();
|
||||
setSortingEnabled(false);
|
||||
|
||||
connect(this, SIGNAL(activated(QModelIndex)), this, SLOT(jumpToItem(QModelIndex)));
|
||||
}
|
||||
|
||||
QV8ProfilerEventRelativesView::~QV8ProfilerEventRelativesView()
|
||||
{
|
||||
}
|
||||
|
||||
void QV8ProfilerEventRelativesView::displayType(int index)
|
||||
{
|
||||
QV8ProfilerDataModel::QV8EventData *event = m_v8Model->v8EventDescription(index);
|
||||
QTC_ASSERT(event, return);
|
||||
|
||||
QList<QV8ProfilerDataModel::QV8EventSub*> events;
|
||||
if (m_type == ParentsView)
|
||||
events = event->parentHash.values();
|
||||
else
|
||||
events = event->childrenHash.values();
|
||||
|
||||
rebuildTree(events);
|
||||
|
||||
updateHeader();
|
||||
resizeColumnToContents(0);
|
||||
setSortingEnabled(true);
|
||||
sortByColumn(1);
|
||||
}
|
||||
|
||||
void QV8ProfilerEventRelativesView::rebuildTree(QList<QV8ProfilerDataModel::QV8EventSub*> events)
|
||||
{
|
||||
clear();
|
||||
|
||||
QStandardItem *topLevelItem = m_model->invisibleRootItem();
|
||||
|
||||
foreach (QV8ProfilerDataModel::QV8EventSub *event, events) {
|
||||
QList<QStandardItem *> newRow;
|
||||
newRow << new V8ViewItem(event->reference->displayName);
|
||||
newRow << new V8ViewItem(QmlProfilerBaseModel::formatTime(event->totalTime));
|
||||
newRow << new V8ViewItem(event->reference->functionName);
|
||||
|
||||
newRow.at(0)->setData(QVariant(event->reference->typeId), TypeIdRole);
|
||||
newRow.at(0)->setData(QVariant(event->reference->filename), FilenameRole);
|
||||
newRow.at(0)->setData(QVariant(event->reference->line), LineRole);
|
||||
newRow.at(1)->setData(QVariant(event->totalTime));
|
||||
newRow.at(2)->setData(QVariant(event->reference->functionName));
|
||||
|
||||
foreach (QStandardItem *item, newRow)
|
||||
item->setEditable(false);
|
||||
|
||||
topLevelItem->appendRow(newRow);
|
||||
}
|
||||
}
|
||||
|
||||
void QV8ProfilerEventRelativesView::clear()
|
||||
{
|
||||
m_model->clear();
|
||||
}
|
||||
|
||||
void QV8ProfilerEventRelativesView::updateHeader()
|
||||
{
|
||||
m_model->setColumnCount(3);
|
||||
|
||||
int columnIndex = 0;
|
||||
if (m_type == ChildrenView)
|
||||
m_model->setHeaderData(columnIndex++, Qt::Horizontal, QVariant(displayHeader(Callee)));
|
||||
else
|
||||
m_model->setHeaderData(columnIndex++, Qt::Horizontal, QVariant(displayHeader(Caller)));
|
||||
|
||||
m_model->setHeaderData(columnIndex++, Qt::Horizontal, QVariant(displayHeader(TotalTime)));
|
||||
|
||||
if (m_type == ChildrenView)
|
||||
m_model->setHeaderData(columnIndex++, Qt::Horizontal, QVariant(displayHeader(CalleeDescription)));
|
||||
else
|
||||
m_model->setHeaderData(columnIndex++, Qt::Horizontal, QVariant(displayHeader(CallerDescription)));
|
||||
}
|
||||
|
||||
void QV8ProfilerEventRelativesView::jumpToItem(const QModelIndex &index)
|
||||
{
|
||||
QStandardItem *infoItem = m_model->item(index.row(), 0);
|
||||
emit typeClicked(infoItem->data(TypeIdRole).toInt());
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace QmlProfiler
|
||||
@@ -1,162 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms and
|
||||
** conditions see http://www.qt.io/terms-conditions. For further information
|
||||
** use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QV8PROFILEREVENTVIEW_H
|
||||
#define QV8PROFILEREVENTVIEW_H
|
||||
|
||||
#include <QStandardItemModel>
|
||||
#include <qmldebug/qmlprofilereventtypes.h>
|
||||
#include "qmlprofilermodelmanager.h"
|
||||
#include "qmlprofilereventsmodelproxy.h"
|
||||
#include "qv8profilerdatamodel.h"
|
||||
#include "qmlprofilertreeview.h"
|
||||
|
||||
#include <analyzerbase/ianalyzertool.h>
|
||||
|
||||
#include "qmlprofilerviewmanager.h"
|
||||
|
||||
namespace QmlProfiler {
|
||||
|
||||
namespace Internal {
|
||||
|
||||
class QV8ProfilerEventsMainView;
|
||||
class QV8ProfilerEventRelativesView;
|
||||
|
||||
|
||||
class QV8ProfilerEventsWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QV8ProfilerEventsWidget(QWidget *parent,
|
||||
QmlProfilerTool *profilerTool,
|
||||
QmlProfilerViewManager *container,
|
||||
QmlProfilerModelManager *profilerModelManager );
|
||||
~QV8ProfilerEventsWidget();
|
||||
|
||||
void clear();
|
||||
|
||||
void getStatisticsInRange(qint64 rangeStart, qint64 rangeEnd);
|
||||
QModelIndex selectedItem() const;
|
||||
bool mouseOnTable(const QPoint &position) const;
|
||||
void copyTableToClipboard() const;
|
||||
void copyRowToClipboard() const;
|
||||
|
||||
signals:
|
||||
void gotoSourceLocation(const QString &fileName, int lineNumber, int columnNumber);
|
||||
void resized();
|
||||
|
||||
public slots:
|
||||
void updateSelectedType(int typeId) const;
|
||||
void selectBySourceLocation(const QString &filename, int line, int column);
|
||||
void updateEnabledState();
|
||||
|
||||
protected:
|
||||
void contextMenuEvent(QContextMenuEvent *ev);
|
||||
virtual void resizeEvent(QResizeEvent *event);
|
||||
|
||||
private:
|
||||
class QV8ProfilerEventsWidgetPrivate;
|
||||
QV8ProfilerEventsWidgetPrivate *d;
|
||||
};
|
||||
|
||||
class QV8ProfilerEventsMainView : public QmlProfilerTreeView
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
explicit QV8ProfilerEventsMainView(QWidget *parent,
|
||||
QV8ProfilerDataModel *v8Model);
|
||||
~QV8ProfilerEventsMainView();
|
||||
|
||||
void setFieldViewable(Fields field, bool show);
|
||||
void setShowAnonymousEvents( bool showThem );
|
||||
|
||||
QModelIndex selectedItem() const;
|
||||
void copyTableToClipboard() const;
|
||||
void copyRowToClipboard() const;
|
||||
|
||||
int selectedTypeId() const;
|
||||
|
||||
void setShowExtendedStatistics(bool);
|
||||
bool showExtendedStatistics() const;
|
||||
|
||||
signals:
|
||||
void gotoSourceLocation(const QString &fileName, int lineNumber, int columnNumber);
|
||||
void typeSelected(int typeId);
|
||||
|
||||
public slots:
|
||||
void clear();
|
||||
void jumpToItem(const QModelIndex &index);
|
||||
void selectType(int typeId);
|
||||
void selectEventByLocation(const QString &filename, int line);
|
||||
void buildModel();
|
||||
|
||||
private:
|
||||
void setHeaderLabels();
|
||||
|
||||
private:
|
||||
class QV8ProfilerEventsMainViewPrivate;
|
||||
QV8ProfilerEventsMainViewPrivate *d;
|
||||
};
|
||||
|
||||
class QV8ProfilerEventRelativesView : public QmlProfilerTreeView
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum SubViewType {
|
||||
ParentsView,
|
||||
ChildrenView
|
||||
};
|
||||
|
||||
QV8ProfilerEventRelativesView(QV8ProfilerDataModel *model, SubViewType viewType,
|
||||
QWidget *parent);
|
||||
~QV8ProfilerEventRelativesView();
|
||||
|
||||
signals:
|
||||
void typeClicked(int typeId);
|
||||
|
||||
public slots:
|
||||
void displayType(int typeId);
|
||||
void jumpToItem(const QModelIndex &);
|
||||
void clear();
|
||||
|
||||
private:
|
||||
void rebuildTree(QList<QV8ProfilerDataModel::QV8EventSub*> events);
|
||||
void updateHeader();
|
||||
|
||||
QV8ProfilerEventRelativesView::SubViewType m_type;
|
||||
QV8ProfilerDataModel *m_v8Model;
|
||||
QStandardItemModel *m_model;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace QmlProfiler
|
||||
|
||||
#endif // QV8PROFILEREVENTVIEW_H
|
||||
Reference in New Issue
Block a user