aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2016-12-19 18:47:06 +0100
committerUlf Hermann <ulf.hermann@qt.io>2017-02-21 10:43:47 +0000
commit548a86f57722fb9513baa87a3562d4138d93970f (patch)
treef515a334a7079bc4014ab1a8887aa2c720060cd1 /src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp
parent8d7feb4bc7fffb37e25bfc706b964f80acb5a5df (diff)
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>
Diffstat (limited to 'src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp')
-rw-r--r--src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp b/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp
index bee5f3deb2..9c396910a7 100644
--- a/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp
+++ b/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp
@@ -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,