QmlProfiler: Expose flush interval to user

Flushing data while the application is running can distort the results
because the flushing itself takes time. However, not flushing leads to
longer load times in the end and higher memory usage. The best strategy
depends on the application being analyzed and the users should decide
if they want to flush or not.

The settings infrastructure also paves the way for preserviing the
layout of the timeline and statistics views as well as the category
filters across sessions.

Change-Id: I2cdc37c7fc7eb9b05b6870955ddffaa712d6c956
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@theqtcompany.com>
Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
This commit is contained in:
Ulf Hermann
2015-08-28 12:50:46 +02:00
parent bd9b487584
commit f1ede40500
21 changed files with 691 additions and 3 deletions

View File

@@ -43,6 +43,7 @@ public:
, recording(false)
, requestedFeatures(0)
, recordedFeatures(0)
, flushInterval(0)
{
::memset(rangeCount, 0, MaximumRangeType * sizeof(int));
}
@@ -62,6 +63,7 @@ public:
bool recording;
quint64 requestedFeatures;
quint64 recordedFeatures;
quint32 flushInterval;
};
} // namespace QmlDebug
@@ -76,7 +78,7 @@ void QmlProfilerTraceClientPrivate::sendRecordingStatus(int engineId)
QDataStream stream(&ba, QIODevice::WriteOnly);
stream << recording << engineId; // engineId -1 is OK. It means "all of them"
if (recording)
stream << requestedFeatures << quint32(1000); // flush interval. Fixed to 1000ms for now
stream << requestedFeatures << flushInterval;
q->sendMessage(ba);
}
@@ -152,6 +154,11 @@ void QmlProfilerTraceClient::setRequestedFeatures(quint64 features)
d->requestedFeatures = features;
}
void QmlProfilerTraceClient::setFlushInterval(quint32 flushInterval)
{
d->flushInterval = flushInterval;
}
void QmlProfilerTraceClient::setRecordingFromServer(bool v)
{
if (v == d->recording)

View File

@@ -63,6 +63,7 @@ public slots:
void clearData();
void sendRecordingStatus(int engineId = -1);
void setRequestedFeatures(quint64 features);
void setFlushInterval(quint32 flushInterval);
signals:
void complete(qint64 maximumTime);

View File

@@ -11,16 +11,20 @@ SOURCES += \
qmlprofilerbasemodel.cpp \
qmlprofilerbindingloopsrenderpass.cpp \
qmlprofilerclientmanager.cpp \
qmlprofilerconfigwidget.cpp \
qmlprofilerdatamodel.cpp \
qmlprofilerdetailsrewriter.cpp \
qmlprofilereventsmodelproxy.cpp \
qmlprofilereventview.cpp \
qmlprofilermodelmanager.cpp \
qmlprofilernotesmodel.cpp \
qmlprofileroptionspage.cpp \
qmlprofilerplugin.cpp \
qmlprofilerrangemodel.cpp \
qmlprofilerrunconfigurationaspect.cpp \
qmlprofilerruncontrol.cpp \
qmlprofilerruncontrolfactory.cpp \
qmlprofilersettings.cpp \
qmlprofilerstatemanager.cpp \
qmlprofilerstatewidget.cpp \
qmlprofilertimelinemodel.cpp \
@@ -39,6 +43,7 @@ HEADERS += \
qmlprofilerbasemodel_p.h \
qmlprofilerbindingloopsrenderpass.h \
qmlprofilerclientmanager.h \
qmlprofilerconfigwidget.h \
qmlprofilerconstants.h \
qmlprofilerdatamodel.h \
qmlprofilerdetailsrewriter.h \
@@ -46,10 +51,13 @@ HEADERS += \
qmlprofilereventview.h \
qmlprofilermodelmanager.h \
qmlprofilernotesmodel.h \
qmlprofileroptionspage.h \
qmlprofilerplugin.h \
qmlprofilerrangemodel.h \
qmlprofilerrunconfigurationaspect.h \
qmlprofilerruncontrol.h \
qmlprofilerruncontrolfactory.h \
qmlprofilersettings.h \
qmlprofilerstatemanager.h \
qmlprofilerstatewidget.h \
qmlprofilertimelinemodel.h \
@@ -65,3 +73,6 @@ RESOURCES += \
DISTFILES += \
qml/bindingloops.frag \
qml/bindingloops.vert
FORMS += \
qmlprofilerconfigwidget.ui

View File

@@ -26,17 +26,21 @@ QtcPlugin {
"qmlprofilerbasemodel.cpp", "qmlprofilerbasemodel.h", "qmlprofilerbasemodel_p.h",
"qmlprofilerbindingloopsrenderpass.cpp","qmlprofilerbindingloopsrenderpass.h",
"qmlprofilerclientmanager.cpp", "qmlprofilerclientmanager.h",
"qmlprofilerconstants.h",
"qmlprofilerconfigwidget.cpp", "qmlprofilerconfigwidget.h",
"qmlprofilerconfigwidget.ui", "qmlprofilerconstants.h",
"qmlprofilerdatamodel.cpp", "qmlprofilerdatamodel.h",
"qmlprofilerdetailsrewriter.cpp", "qmlprofilerdetailsrewriter.h",
"qmlprofilereventsmodelproxy.cpp", "qmlprofilereventsmodelproxy.h",
"qmlprofilereventview.cpp", "qmlprofilereventview.h",
"qmlprofilermodelmanager.cpp", "qmlprofilermodelmanager.h",
"qmlprofilernotesmodel.cpp", "qmlprofilernotesmodel.h",
"qmlprofileroptionspage.cpp", "qmlprofileroptionspage.h",
"qmlprofilerplugin.cpp", "qmlprofilerplugin.h",
"qmlprofilerrunconfigurationaspect.cpp", "qmlprofilerrunconfigurationaspect.h",
"qmlprofilerruncontrolfactory.cpp", "qmlprofilerruncontrolfactory.h",
"qmlprofilerrangemodel.cpp", "qmlprofilerrangemodel.h",
"qmlprofilerruncontrol.cpp", "qmlprofilerruncontrol.h",
"qmlprofilersettings.cpp", "qmlprofilersettings.h",
"qmlprofilerstatemanager.cpp", "qmlprofilerstatemanager.h",
"qmlprofilerstatewidget.cpp", "qmlprofilerstatewidget.h",
"qmlprofilertimelinemodel.cpp", "qmlprofilertimelinemodel.h",

View File

@@ -67,6 +67,7 @@ public:
quint64 tcpPort;
QString ostDevice;
QString sysroot;
quint32 flushInterval;
bool qmlDataReady;
@@ -83,6 +84,7 @@ QmlProfilerClientManager::QmlProfilerClientManager(QObject *parent) :
d->connection = 0;
d->connectionAttempts = 0;
d->qmlDataReady = false;
d->flushInterval = 0;
d->modelManager = 0;
@@ -106,6 +108,11 @@ void QmlProfilerClientManager::setModelManager(QmlProfilerModelManager *m)
connect(this,SIGNAL(dataReadyForProcessing()), d->modelManager, SLOT(complete()));
}
void QmlProfilerClientManager::setFlushInterval(quint32 flushInterval)
{
d->flushInterval = flushInterval;
}
void QmlProfilerClientManager::setTcpConnection(QString host, quint64 port)
{
d->connectMode = QmlProfilerClientManagerPrivate::TcpConnection;
@@ -154,6 +161,7 @@ void QmlProfilerClientManager::enableServices()
d->profilerState->setRecordedFeatures(0);
d->qmlclientplugin = new QmlProfilerTraceClient(d->connection,
d->profilerState->requestedFeatures());
d->qmlclientplugin->setFlushInterval(d->flushInterval);
connectClientSignals();
}

View File

@@ -59,6 +59,8 @@ public:
bool isConnected() const;
void setModelManager(QmlProfilerModelManager *m);
void setFlushInterval(quint32 flushInterval);
signals:
void connectionFailed();
void connectionClosed();

View File

@@ -0,0 +1,65 @@
/****************************************************************************
**
** 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 "qmlprofilerconfigwidget.h"
#include "ui_qmlprofilerconfigwidget.h"
namespace QmlProfiler {
namespace Internal {
QmlProfilerConfigWidget::QmlProfilerConfigWidget(QmlProfilerSettings *settings, QWidget *parent) :
QWidget(parent), m_ui(new Ui::QmlProfilerConfigWidget), m_settings(settings)
{
m_ui->setupUi(this);
updateUi();
connect(m_ui->flushEnabled, &QCheckBox::toggled,
m_settings, &QmlProfilerSettings::setFlushEnabled);
connect(m_ui->flushInterval, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
m_settings, &QmlProfilerSettings::setFlushInterval);
connect(m_settings, &QmlProfilerSettings::changed, this, &QmlProfilerConfigWidget::updateUi);
}
QmlProfilerConfigWidget::~QmlProfilerConfigWidget()
{
delete m_ui;
}
void QmlProfilerConfigWidget::updateUi()
{
m_ui->flushEnabled->setChecked(m_settings->flushEnabled());
m_ui->flushInterval->setEnabled(m_settings->flushEnabled());
m_ui->flushInterval->setValue(m_settings->flushInterval());
}
} // Internal
} // QmlProfiler

View File

@@ -0,0 +1,64 @@
/****************************************************************************
**
** 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 QMLPROFILERCONFIGWIDGET_H
#define QMLPROFILERCONFIGWIDGET_H
#include "qmlprofilersettings.h"
#include <QWidget>
namespace QmlProfiler {
namespace Internal {
namespace Ui {
class QmlProfilerConfigWidget;
}
class QmlProfilerConfigWidget : public QWidget
{
Q_OBJECT
public:
explicit QmlProfilerConfigWidget(QmlProfilerSettings *settings, QWidget *parent = 0);
~QmlProfilerConfigWidget();
private slots:
void updateUi();
private:
Ui::QmlProfilerConfigWidget *m_ui;
QmlProfilerSettings *m_settings;
};
} // Internal
} // QmlProfiler
#endif // QMLPROFILERCONFIGWIDGET_H

View File

@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QmlProfiler::Internal::QmlProfilerConfigWidget</class>
<widget class="QWidget" name="QmlProfiler::Internal::QmlProfilerConfigWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>320</width>
<height>100</height>
</rect>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="flushEnabledLabel">
<property name="text">
<string>Flush data while profiling:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="flushEnabled">
<property name="toolTip">
<string>Periodically flush pending data to Qt Creator. This reduces the delay when loading the
data and the memory usage in the application. It distorts the profile as the flushing
itself takes time. </string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="flushIntervalLabel">
<property name="text">
<string>Flush interval (ms):</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="flushInterval">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>10000000</number>
</property>
<property name="value">
<number>1000</number>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -38,6 +38,10 @@ const char ATTACH[] = "Menu.Analyzer.Attach";
const char TraceFileExtension[] = ".qtd";
const char TASK_LOAD[] = "QmlProfiler.TaskLoad";
const char TASK_SAVE[] = "QmlProfiler.TaskSave";
const char FLUSH_ENABLED[] = "Analyzer.QmlProfiler.FlushEnabled";
const char FLUSH_INTERVAL[] = "Analyzer.QmlProfiler.FlushInterval";
const char SETTINGS[] = "Analyzer.QmlProfiler.Settings";
const char ANALYZER[] = "Analyzer";
} // namespace Constants
} // namespace QmlProfiler

View File

@@ -0,0 +1,72 @@
/****************************************************************************
**
** 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 "qmlprofileroptionspage.h"
#include "qmlprofilerconfigwidget.h"
#include "qmlprofilerplugin.h"
#include "qmlprofilerconstants.h"
namespace QmlProfiler {
namespace Internal {
QmlProfilerOptionsPage::QmlProfilerOptionsPage()
{
setId(Constants::SETTINGS);
setDisplayName(tr("QML Profiler"));
setCategory("T.Analyzer");
setDisplayCategory(tr("Analyzer"));
setCategoryIcon(QLatin1String(":/images/analyzer_category.png"));
}
QmlProfilerOptionsPage::~QmlProfilerOptionsPage()
{
delete m_widget;
}
QWidget *QmlProfilerOptionsPage::widget()
{
if (!m_widget)
m_widget = new QmlProfilerConfigWidget(QmlProfilerPlugin::globalSettings(), 0);
return m_widget;
}
void QmlProfilerOptionsPage::apply()
{
QmlProfilerPlugin::globalSettings()->writeGlobalSettings();
}
void QmlProfilerOptionsPage::finish()
{
delete m_widget;
m_widget = 0;
}
} // Internal
} // QmlProfiler

View File

@@ -0,0 +1,56 @@
/****************************************************************************
**
** 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 QMLPROFILEROPTIONSPAGE_H
#define QMLPROFILEROPTIONSPAGE_H
#include <coreplugin/dialogs/ioptionspage.h>
namespace QmlProfiler {
namespace Internal {
class QmlProfilerOptionsPage : public Core::IOptionsPage
{
public:
QmlProfilerOptionsPage();
~QmlProfilerOptionsPage();
QWidget *widget();
void apply();
void finish();
private:
QWidget *m_widget;
};
} // Internal
} // QmlProfiler
#endif // QMLPROFILEROPTIONSPAGE_H

View File

@@ -30,7 +30,7 @@
#include "qmlprofilerplugin.h"
#include "qmlprofilerruncontrolfactory.h"
#include "qmlprofileroptionspage.h"
#include "qmlprofilertool.h"
#include "qmlprofilertimelinemodel.h"
@@ -44,6 +44,8 @@ using namespace Analyzer;
namespace QmlProfiler {
namespace Internal {
Q_GLOBAL_STATIC(QmlProfilerSettings, qmlProfilerGlobalSettings)
bool QmlProfilerPlugin::debugOutput = false;
QmlProfilerPlugin *QmlProfilerPlugin::instance = 0;
@@ -91,6 +93,7 @@ bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorS
AnalyzerManager::addAction(action);
addAutoReleasedObject(new QmlProfilerRunControlFactory());
addAutoReleasedObject(new Internal::QmlProfilerOptionsPage());
QmlProfilerPlugin::instance = this;
return true;
@@ -117,5 +120,10 @@ QList<QmlProfilerTimelineModel *> QmlProfilerPlugin::getModels(QmlProfilerModelM
return QList<QmlProfilerTimelineModel *>();
}
QmlProfilerSettings *QmlProfilerPlugin::globalSettings()
{
return qmlProfilerGlobalSettings();
}
} // namespace Internal
} // namespace QmlProfiler

View File

@@ -33,6 +33,7 @@
#include "qmlprofiler_global.h"
#include "qmlprofilertimelinemodelfactory.h"
#include "qmlprofilersettings.h"
#include <extensionsystem/iplugin.h>
#include "qmlprofilertimelinemodel.h"
@@ -56,6 +57,7 @@ public:
static QmlProfilerPlugin *instance;
QList<QmlProfilerTimelineModel *> getModels(QmlProfilerModelManager *manager) const;
static QmlProfilerSettings *globalSettings();
private:
QmlProfilerTimelineModelFactory *factory;

View File

@@ -0,0 +1,65 @@
/****************************************************************************
**
** 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 "qmlprofilerrunconfigurationaspect.h"
#include "qmlprofilersettings.h"
#include "qmlprofilerplugin.h"
#include "qmlprofilerconstants.h"
#include <analyzerbase/analyzerrunconfigwidget.h>
namespace QmlProfiler {
namespace Internal {
QmlProfilerRunConfigurationAspect::QmlProfilerRunConfigurationAspect(
ProjectExplorer::RunConfiguration *parent) :
ProjectExplorer::IRunConfigurationAspect(parent)
{
setProjectSettings(new QmlProfilerSettings());
setGlobalSettings(QmlProfilerPlugin::globalSettings());
setId(Constants::SETTINGS);
setDisplayName(tr("QML Profiler Settings"));
setUsingGlobalSettings(true);
resetProjectToGlobalSettings();
}
ProjectExplorer::IRunConfigurationAspect *QmlProfilerRunConfigurationAspect::create(
ProjectExplorer::RunConfiguration *runConfig) const
{
return new QmlProfilerRunConfigurationAspect(runConfig);
}
ProjectExplorer::RunConfigWidget *QmlProfilerRunConfigurationAspect::createConfigurationWidget()
{
return new Analyzer::AnalyzerRunConfigWidget(this);
}
} // Internal
} // QmlProfiler

View File

@@ -0,0 +1,53 @@
/****************************************************************************
**
** 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 QMLPROFILERRUNCONFIGURATIONASPECT_H
#define QMLPROFILERRUNCONFIGURATIONASPECT_H
#include <projectexplorer/runconfiguration.h>
namespace QmlProfiler {
namespace Internal {
class QmlProfilerRunConfigurationAspect : public ProjectExplorer::IRunConfigurationAspect
{
public:
QmlProfilerRunConfigurationAspect(ProjectExplorer::RunConfiguration *parent);
ProjectExplorer::IRunConfigurationAspect *create(
ProjectExplorer::RunConfiguration *runConfig) const;
ProjectExplorer::RunConfigWidget *createConfigurationWidget();
};
} // Internal
} // QmlProfiler
#endif // QMLPROFILERRUNCONFIGURATIONASPECT_H

View File

@@ -31,6 +31,7 @@
#include "qmlprofilerruncontrolfactory.h"
#include "localqmlprofilerrunner.h"
#include "qmlprofilerruncontrol.h"
#include "qmlprofilerrunconfigurationaspect.h"
#include <analyzerbase/ianalyzertool.h>
@@ -92,5 +93,11 @@ RunControl *QmlProfilerRunControlFactory::create(RunConfiguration *runConfigurat
return LocalQmlProfilerRunner::createLocalRunControl(runConfiguration, sp, errorMessage);
}
ProjectExplorer::IRunConfigurationAspect *
QmlProfilerRunControlFactory::createRunConfigurationAspect(ProjectExplorer::RunConfiguration *rc)
{
return new QmlProfilerRunConfigurationAspect(rc);
}
} // namespace Internal
} // namespace QmlProfiler

View File

@@ -50,6 +50,9 @@ public:
ProjectExplorer::RunControl *create(RunConfiguration *runConfiguration,
Core::Id mode,
QString *errorMessage);
ProjectExplorer::IRunConfigurationAspect *createRunConfigurationAspect(
ProjectExplorer::RunConfiguration *rc);
};
} // namespace Internal

View File

@@ -0,0 +1,120 @@
/****************************************************************************
**
** 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 "qmlprofilersettings.h"
#include "qmlprofilerconstants.h"
#include "qmlprofilerconfigwidget.h"
#include <coreplugin/icore.h>
#include <QSettings>
namespace QmlProfiler {
namespace Internal {
QmlProfilerSettings::QmlProfilerSettings()
{
QVariantMap defaults;
defaults.insert(QLatin1String(Constants::FLUSH_INTERVAL), 1000);
defaults.insert(QLatin1String(Constants::FLUSH_ENABLED), false);
// Read stored values
QSettings *settings = Core::ICore::settings();
settings->beginGroup(QLatin1String(Constants::ANALYZER));
QVariantMap map = defaults;
for (QVariantMap::ConstIterator it = defaults.constBegin(); it != defaults.constEnd(); ++it)
map.insert(it.key(), settings->value(it.key(), it.value()));
settings->endGroup();
fromMap(map);
}
QWidget *QmlProfilerSettings::createConfigWidget(QWidget *parent)
{
return new Internal::QmlProfilerConfigWidget(this, parent);
}
ProjectExplorer::ISettingsAspect *QmlProfilerSettings::create() const
{
return new QmlProfilerSettings;
}
bool QmlProfilerSettings::flushEnabled() const
{
return m_flushEnabled;
}
void QmlProfilerSettings::setFlushEnabled(bool flushEnabled)
{
if (m_flushEnabled != flushEnabled) {
m_flushEnabled = flushEnabled;
emit changed();
}
}
quint32 QmlProfilerSettings::flushInterval() const
{
return m_flushInterval;
}
void QmlProfilerSettings::setFlushInterval(quint32 flushInterval)
{
if (m_flushInterval != flushInterval) {
m_flushInterval = flushInterval;
emit changed();
}
}
void QmlProfilerSettings::writeGlobalSettings() const
{
QSettings *settings = Core::ICore::settings();
settings->beginGroup(QLatin1String(Constants::ANALYZER));
QVariantMap map;
toMap(map);
for (QVariantMap::ConstIterator it = map.constBegin(); it != map.constEnd(); ++it)
settings->setValue(it.key(), it.value());
settings->endGroup();
}
void QmlProfilerSettings::toMap(QVariantMap &map) const
{
map[QLatin1String(Constants::FLUSH_INTERVAL)] = m_flushInterval;
map[QLatin1String(Constants::FLUSH_ENABLED)] = m_flushEnabled;
}
void QmlProfilerSettings::fromMap(const QVariantMap &map)
{
m_flushEnabled = map.value(QLatin1String(Constants::FLUSH_ENABLED)).toBool();
m_flushInterval = map.value(QLatin1String(Constants::FLUSH_INTERVAL)).toUInt();
emit changed();
}
} // Internal
} // QmlProfiler

View File

@@ -0,0 +1,70 @@
/****************************************************************************
**
** 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 QMLPROFILERSETTINGS_H
#define QMLPROFILERSETTINGS_H
#include <projectexplorer/runconfiguration.h>
namespace QmlProfiler {
namespace Internal {
class QmlProfilerSettings : public ProjectExplorer::ISettingsAspect
{
Q_OBJECT
public:
QmlProfilerSettings();
QWidget *createConfigWidget(QWidget *parent);
ProjectExplorer::ISettingsAspect *create() const;
bool flushEnabled() const;
void setFlushEnabled(bool flushEnabled);
quint32 flushInterval() const;
void setFlushInterval(quint32 flushInterval);
void writeGlobalSettings() const;
signals:
void changed();
protected:
void toMap(QVariantMap &map) const;
void fromMap(const QVariantMap &map);
private:
bool m_flushEnabled;
quint32 m_flushInterval;
};
} // Internal
} // QmlProfiler
#endif // QMLPROFILERSETTINGS_H

View File

@@ -38,6 +38,8 @@
#include "qmlprofilermodelmanager.h"
#include "qmlprofilerdetailsrewriter.h"
#include "qmlprofilernotesmodel.h"
#include "qmlprofilerrunconfigurationaspect.h"
#include "qmlprofilersettings.h"
#include <analyzerbase/analyzermanager.h>
#include <analyzerbase/analyzerruncontrol.h>
@@ -190,6 +192,16 @@ QmlProfilerTool::~QmlProfilerTool()
AnalyzerRunControl *QmlProfilerTool::createRunControl(const AnalyzerStartParameters &sp,
RunConfiguration *runConfiguration)
{
QmlProfilerRunConfigurationAspect *aspect = static_cast<QmlProfilerRunConfigurationAspect *>(
runConfiguration->extraAspect(Constants::SETTINGS));
QTC_ASSERT(aspect, return 0);
QmlProfilerSettings *settings = static_cast<QmlProfilerSettings *>(aspect->currentSettings());
QTC_ASSERT(settings, return 0);
d->m_profilerConnections->setFlushInterval(settings->flushEnabled() ?
settings->flushInterval() : 0);
QmlProfilerRunControl *engine = new QmlProfilerRunControl(sp, runConfiguration);
engine->registerProfilerStateManager(d->m_profilerState);