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:
@@ -36,6 +36,7 @@
|
||||
#include "qmlprofilerrunconfigurationaspect.h"
|
||||
#include "qmlprofilersettings.h"
|
||||
#include "qmlprofilerplugin.h"
|
||||
#include "qmlprofilertextmark.h"
|
||||
|
||||
#include <debugger/debuggericons.h>
|
||||
#include <debugger/analyzer/analyzermanager.h>
|
||||
@@ -285,6 +286,15 @@ QmlProfilerTool::QmlProfilerTool(QObject *parent)
|
||||
|
||||
connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::updateRunActions,
|
||||
this, &QmlProfilerTool::updateRunActions);
|
||||
|
||||
QmlProfilerTextMarkModel *model = d->m_profilerModelManager->textMarkModel();
|
||||
if (EditorManager *editorManager = EditorManager::instance()) {
|
||||
connect(editorManager, &EditorManager::editorCreated,
|
||||
model, [this, model](Core::IEditor *editor, const QString &fileName) {
|
||||
Q_UNUSED(editor);
|
||||
model->createMarks(this, fileName);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
QmlProfilerTool::~QmlProfilerTool()
|
||||
@@ -463,6 +473,11 @@ void QmlProfilerTool::gotoSourceLocation(const QString &fileUrl, int lineNumber,
|
||||
EditorManager::DoNotSwitchToDesignMode | EditorManager::DoNotSwitchToEditMode);
|
||||
}
|
||||
|
||||
void QmlProfilerTool::selectType(int typeId)
|
||||
{
|
||||
d->m_viewContainer->typeSelected(typeId);
|
||||
}
|
||||
|
||||
void QmlProfilerTool::updateTimeDisplay()
|
||||
{
|
||||
double seconds = 0;
|
||||
@@ -517,6 +532,18 @@ void QmlProfilerTool::setButtonsEnabled(bool enable)
|
||||
d->m_recordFeaturesMenu->setEnabled(enable);
|
||||
}
|
||||
|
||||
void QmlProfilerTool::createTextMarks()
|
||||
{
|
||||
QmlProfilerTextMarkModel *model = d->m_profilerModelManager->textMarkModel();
|
||||
foreach (IDocument *document, DocumentModel::openedDocuments())
|
||||
model->createMarks(this, document->filePath().toString());
|
||||
}
|
||||
|
||||
void QmlProfilerTool::clearTextMarks()
|
||||
{
|
||||
d->m_profilerModelManager->textMarkModel()->clear();
|
||||
}
|
||||
|
||||
bool QmlProfilerTool::prepareTool()
|
||||
{
|
||||
if (d->m_recordButton->isChecked()) {
|
||||
@@ -574,6 +601,16 @@ void QmlProfilerTool::startRemoteTool(ProjectExplorer::RunConfiguration *rc)
|
||||
ProjectExplorerPlugin::startRunControl(runControl, ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
|
||||
}
|
||||
|
||||
QString QmlProfilerTool::summary(const QVector<int> &typeIds) const
|
||||
{
|
||||
return d->m_viewContainer->statisticsView()->summary(typeIds);
|
||||
}
|
||||
|
||||
QStringList QmlProfilerTool::details(int typeId) const
|
||||
{
|
||||
return d->m_viewContainer->statisticsView()->details(typeId);
|
||||
}
|
||||
|
||||
void QmlProfilerTool::logState(const QString &msg)
|
||||
{
|
||||
MessageManager::write(msg, MessageManager::Flash);
|
||||
@@ -765,6 +802,7 @@ void QmlProfilerTool::profilerDataModelStateChanged()
|
||||
setButtonsEnabled(true);
|
||||
break;
|
||||
case QmlProfilerModelManager::ClearingData :
|
||||
clearTextMarks();
|
||||
d->m_recordButton->setEnabled(false);
|
||||
setButtonsEnabled(false);
|
||||
clearDisplay();
|
||||
@@ -783,6 +821,7 @@ void QmlProfilerTool::profilerDataModelStateChanged()
|
||||
updateTimeDisplay();
|
||||
d->m_recordButton->setEnabled(true);
|
||||
setButtonsEnabled(true);
|
||||
createTextMarks();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
Reference in New Issue
Block a user