forked from qt-creator/qt-creator
QmlProfiler: Add text marks for QML/JS types into documents
The text marks are little labels next to the lines in the editor that tell you how much of total run time was spent in the respective QML/JS construct during the last profiling session. This is similar to what the valgrind profiler does. We add the text marks only when the documents are loaded into an editor. This keeps the number of text marks manageable. Multiple events on a single line are shown using a tooltip. Task-number: QTCREATORBUG-17757 Change-Id: Ie38b8ab880a718a1ef72ef343d84070ab34bc5bc Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -138,6 +138,7 @@ class QmlProfilerModelManager::QmlProfilerModelManagerPrivate
|
||||
public:
|
||||
QmlProfilerDataModel *model;
|
||||
QmlProfilerNotesModel *notesModel;
|
||||
QmlProfilerTextMarkModel *textMarkModel;
|
||||
|
||||
QmlProfilerModelManager::State state;
|
||||
QmlProfilerTraceTime *traceTime;
|
||||
@@ -172,6 +173,7 @@ QmlProfilerModelManager::QmlProfilerModelManager(QObject *parent) :
|
||||
d->state = Empty;
|
||||
d->traceTime = new QmlProfilerTraceTime(this);
|
||||
d->notesModel = new QmlProfilerNotesModel(this);
|
||||
d->textMarkModel = new QmlProfilerTextMarkModel(this);
|
||||
connect(d->model, &QmlProfilerDataModel::allTypesLoaded,
|
||||
this, &QmlProfilerModelManager::processingDone);
|
||||
}
|
||||
@@ -196,6 +198,11 @@ QmlProfilerNotesModel *QmlProfilerModelManager::notesModel() const
|
||||
return d->notesModel;
|
||||
}
|
||||
|
||||
QmlProfilerTextMarkModel *QmlProfilerModelManager::textMarkModel() const
|
||||
{
|
||||
return d->textMarkModel;
|
||||
}
|
||||
|
||||
bool QmlProfilerModelManager::isEmpty() const
|
||||
{
|
||||
return d->model->isEmpty();
|
||||
@@ -242,12 +249,29 @@ void QmlProfilerModelManager::addEvent(const QmlEvent &event)
|
||||
|
||||
void QmlProfilerModelManager::addEventTypes(const QVector<QmlEventType> &types)
|
||||
{
|
||||
const int firstTypeId = d->model->eventTypes().count();
|
||||
d->model->addEventTypes(types);
|
||||
for (int i = 0, end = types.length(); i < end; ++i) {
|
||||
const QmlEventLocation &location = types[i].location();
|
||||
if (location.isValid()) {
|
||||
d->textMarkModel->addTextMarkId(
|
||||
firstTypeId + i, QmlEventLocation(
|
||||
d->model->findLocalFile(location.filename()), location.line(),
|
||||
location.column()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QmlProfilerModelManager::addEventType(const QmlEventType &type)
|
||||
{
|
||||
const int typeId = d->model->eventTypes().count();
|
||||
d->model->addEventType(type);
|
||||
const QmlEventLocation &location = type.location();
|
||||
if (location.isValid()) {
|
||||
d->textMarkModel->addTextMarkId(
|
||||
typeId, QmlEventLocation(d->model->findLocalFile(location.filename()),
|
||||
location.line(), location.column()));
|
||||
}
|
||||
}
|
||||
|
||||
void QmlProfilerModelManager::QmlProfilerModelManagerPrivate::dispatch(const QmlEvent &event,
|
||||
|
Reference in New Issue
Block a user