forked from qt-creator/qt-creator
qmlprofiler: ui and style
Change-Id: I2153ef00f8d3c6d1cc4d39648916cad865b5a9be Reviewed-on: http://codereview.qt.nokia.com/54 Reviewed-by: hjk
This commit is contained in:
@@ -55,34 +55,15 @@
|
||||
#include "canvas/qdeclarativetiledcanvas_p.h"
|
||||
|
||||
|
||||
|
||||
using namespace QmlProfiler::Internal;
|
||||
|
||||
namespace QmlProfiler {
|
||||
namespace Internal {
|
||||
|
||||
//
|
||||
// QmlProfilerEnginePrivate
|
||||
//
|
||||
|
||||
class QmlProfilerEngine::QmlProfilerEnginePrivate
|
||||
{
|
||||
public:
|
||||
QmlProfilerEnginePrivate(QmlProfilerEngine *qq) : q(qq), m_runner(0) {}
|
||||
~QmlProfilerEnginePrivate() {}
|
||||
|
||||
bool attach(const QString &address, uint port);
|
||||
static AbstractQmlProfilerRunner *createRunner(const Analyzer::AnalyzerStartParameters &m_params, QObject *parent);
|
||||
|
||||
QmlProfilerEngine *q;
|
||||
|
||||
Analyzer::AnalyzerStartParameters m_params;
|
||||
AbstractQmlProfilerRunner *m_runner;
|
||||
bool m_running;
|
||||
bool m_fetchingData;
|
||||
bool m_delayedDelete;
|
||||
};
|
||||
|
||||
AbstractQmlProfilerRunner *
|
||||
QmlProfilerEngine::QmlProfilerEnginePrivate::createRunner(const Analyzer::AnalyzerStartParameters &m_params, QObject *parent)
|
||||
static AbstractQmlProfilerRunner *
|
||||
createRunner(const Analyzer::AnalyzerStartParameters &m_params, QObject *parent)
|
||||
{
|
||||
AbstractQmlProfilerRunner *runner = 0;
|
||||
if (m_params.startMode == Analyzer::StartLocal) {
|
||||
@@ -101,16 +82,35 @@ QmlProfilerEngine::QmlProfilerEnginePrivate::createRunner(const Analyzer::Analyz
|
||||
return runner;
|
||||
}
|
||||
|
||||
|
||||
class QmlProfilerEngine::QmlProfilerEnginePrivate
|
||||
{
|
||||
public:
|
||||
QmlProfilerEnginePrivate(QmlProfilerEngine *qq) : q(qq), m_runner(0) {}
|
||||
~QmlProfilerEnginePrivate() {}
|
||||
|
||||
bool attach(const QString &address, uint port);
|
||||
|
||||
QmlProfilerEngine *q;
|
||||
|
||||
Analyzer::AnalyzerStartParameters m_params;
|
||||
AbstractQmlProfilerRunner *m_runner;
|
||||
bool m_running;
|
||||
bool m_fetchingData;
|
||||
bool m_delayedDelete;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// QmlProfilerEngine
|
||||
//
|
||||
|
||||
QmlProfilerEngine::QmlProfilerEngine(const Analyzer::AnalyzerStartParameters &sp, ProjectExplorer::RunConfiguration *runConfiguration)
|
||||
QmlProfilerEngine::QmlProfilerEngine(const Analyzer::AnalyzerStartParameters &sp,
|
||||
ProjectExplorer::RunConfiguration *runConfiguration)
|
||||
: IAnalyzerEngine(sp, runConfiguration)
|
||||
, d(new QmlProfilerEnginePrivate(this))
|
||||
{
|
||||
d->m_params = sp;
|
||||
|
||||
d->m_running = false;
|
||||
d->m_fetchingData = false;
|
||||
d->m_delayedDelete = false;
|
||||
@@ -126,7 +126,7 @@ QmlProfilerEngine::~QmlProfilerEngine()
|
||||
void QmlProfilerEngine::start()
|
||||
{
|
||||
QTC_ASSERT(!d->m_runner, return);
|
||||
d->m_runner = QmlProfilerEnginePrivate::createRunner(d->m_params, this);
|
||||
d->m_runner = createRunner(d->m_params, this);
|
||||
QTC_ASSERT(d->m_runner, return);
|
||||
|
||||
connect(d->m_runner, SIGNAL(started()), this, SIGNAL(processRunning()));
|
||||
@@ -163,7 +163,8 @@ void QmlProfilerEngine::setFetchingData(bool b)
|
||||
d->m_fetchingData = b;
|
||||
}
|
||||
|
||||
void QmlProfilerEngine::dataReceived() {
|
||||
void QmlProfilerEngine::dataReceived()
|
||||
{
|
||||
if (d->m_delayedDelete)
|
||||
finishProcess();
|
||||
d->m_delayedDelete = false;
|
||||
@@ -175,7 +176,6 @@ void QmlProfilerEngine::finishProcess()
|
||||
if (d->m_running) {
|
||||
d->m_running = false;
|
||||
d->m_runner->stop();
|
||||
|
||||
emit finished();
|
||||
}
|
||||
}
|
||||
@@ -184,3 +184,6 @@ void QmlProfilerEngine::logApplicationMessage(const QString &msg, Utils::OutputF
|
||||
{
|
||||
qDebug() << "app: " << msg;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace QmlProfiler
|
||||
|
||||
@@ -58,7 +58,6 @@ class QmlProfilerSummaryView::QmlProfilerSummaryViewPrivate
|
||||
{
|
||||
public:
|
||||
QmlProfilerSummaryViewPrivate(QmlProfilerSummaryView *qq) : q(qq) {}
|
||||
~QmlProfilerSummaryViewPrivate() {}
|
||||
|
||||
QmlProfilerSummaryView *q;
|
||||
|
||||
@@ -79,9 +78,9 @@ public:
|
||||
class ProfilerItem : public QStandardItem
|
||||
{
|
||||
public:
|
||||
ProfilerItem(const QString &text):QStandardItem ( text ) {}
|
||||
ProfilerItem(const QString &text) : QStandardItem(text) {}
|
||||
|
||||
virtual bool operator< ( const QStandardItem & other ) const
|
||||
virtual bool operator<(const QStandardItem &other) const
|
||||
{
|
||||
if (data().type() == QVariant::String) {
|
||||
// first column
|
||||
@@ -124,7 +123,7 @@ void QmlProfilerSummaryView::clean()
|
||||
d->m_model->setColumnCount(7);
|
||||
|
||||
// clean the hash
|
||||
QHashIterator<QString, BindingData *>it(d->m_bindingHash);
|
||||
QHashIterator<QString, BindingData *> it(d->m_bindingHash);
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
delete it.value();
|
||||
@@ -135,7 +134,8 @@ void QmlProfilerSummaryView::clean()
|
||||
setSortingEnabled(false);
|
||||
}
|
||||
|
||||
void QmlProfilerSummaryView::addRangedEvent(int type, qint64 startTime, qint64 length, const QStringList &data, const QString &fileName, int line)
|
||||
void QmlProfilerSummaryView::addRangedEvent(int type, qint64 startTime, qint64 length,
|
||||
const QStringList &data, const QString &fileName, int line)
|
||||
{
|
||||
Q_UNUSED(startTime);
|
||||
Q_UNUSED(data);
|
||||
@@ -191,7 +191,7 @@ void QmlProfilerSummaryView::complete()
|
||||
it.next();
|
||||
BindingData *binding = it.value();
|
||||
binding->percent = binding->duration * 100.0 / totalTime;
|
||||
binding->tpc = binding->calls>0? (double)binding->duration / binding->calls : 0;
|
||||
binding->tpc = binding->calls > 0 ? double(binding->duration) / binding->calls : 0;
|
||||
|
||||
appendRow(binding->displayname,
|
||||
binding->filename,
|
||||
@@ -228,7 +228,7 @@ void QmlProfilerSummaryView::appendRow(const QString &displayName,
|
||||
double maxTime,
|
||||
double minTime)
|
||||
{
|
||||
QString location =fileName+QLatin1Char(':')+QString::number(line);
|
||||
QString location = fileName + QLatin1Char(':') + QString::number(line);
|
||||
ProfilerItem *locationColumn = new ProfilerItem(displayName);
|
||||
locationColumn->setData(QVariant(location),Qt::UserRole+1);
|
||||
locationColumn->setData(QVariant(fileName),Qt::UserRole+2);
|
||||
@@ -260,9 +260,9 @@ void QmlProfilerSummaryView::appendRow(const QString &displayName,
|
||||
|
||||
QString QmlProfilerSummaryView::displayTime(double time) const
|
||||
{
|
||||
if (time<1e6)
|
||||
if (time < 1e6)
|
||||
return QString::number(time/1e3,'f',3) + QString::fromWCharArray(L" \u03BCs");
|
||||
if (time<1e9)
|
||||
if (time < 1e9)
|
||||
return QString::number(time/1e6,'f',3) + QLatin1String(" ms");
|
||||
|
||||
return QString::number(time/1e9,'f',3) + QLatin1String(" s");
|
||||
@@ -270,11 +270,11 @@ QString QmlProfilerSummaryView::displayTime(double time) const
|
||||
|
||||
void QmlProfilerSummaryView::setHeaderLabels()
|
||||
{
|
||||
d->m_model->setHeaderData(0,Qt::Horizontal,QVariant(tr("location")));
|
||||
d->m_model->setHeaderData(1,Qt::Horizontal,QVariant(tr("% time")));
|
||||
d->m_model->setHeaderData(2,Qt::Horizontal,QVariant(tr("total time")));
|
||||
d->m_model->setHeaderData(3,Qt::Horizontal,QVariant(tr("calls")));
|
||||
d->m_model->setHeaderData(4,Qt::Horizontal,QVariant(tr("time per call")));
|
||||
d->m_model->setHeaderData(5,Qt::Horizontal,QVariant(tr("longest time")));
|
||||
d->m_model->setHeaderData(6,Qt::Horizontal,QVariant(tr("shortest time")));
|
||||
d->m_model->setHeaderData(0, Qt::Horizontal, QVariant(tr("Location")));
|
||||
d->m_model->setHeaderData(1, Qt::Horizontal, QVariant(tr("Time in Percent")));
|
||||
d->m_model->setHeaderData(2, Qt::Horizontal, QVariant(tr("Total Time")));
|
||||
d->m_model->setHeaderData(3, Qt::Horizontal, QVariant(tr("Calls")));
|
||||
d->m_model->setHeaderData(4, Qt::Horizontal, QVariant(tr("Time per Call")));
|
||||
d->m_model->setHeaderData(5, Qt::Horizontal, QVariant(tr("Longest Time")));
|
||||
d->m_model->setHeaderData(6, Qt::Horizontal, QVariant(tr("Shortest Time")));
|
||||
}
|
||||
|
||||
@@ -103,17 +103,17 @@ public:
|
||||
QmlProfilerTool::QmlProfilerTool(QObject *parent)
|
||||
: IAnalyzerTool(parent), d(new QmlProfilerToolPrivate(this))
|
||||
{
|
||||
d->m_client = 0;
|
||||
d->m_connectionAttempts = 0;
|
||||
d->m_traceWindow = 0;
|
||||
d->m_project = 0;
|
||||
d->m_runConfiguration = 0;
|
||||
d->m_isAttached = false;
|
||||
d->m_attachAction = 0;
|
||||
d->m_recordingEnabled = true;
|
||||
d->m_client = 0;
|
||||
d->m_connectionAttempts = 0;
|
||||
d->m_traceWindow = 0;
|
||||
d->m_project = 0;
|
||||
d->m_runConfiguration = 0;
|
||||
d->m_isAttached = false;
|
||||
d->m_attachAction = 0;
|
||||
d->m_recordingEnabled = true;
|
||||
|
||||
d->m_connectionTimer.setInterval(200);
|
||||
connect(&d->m_connectionTimer, SIGNAL(timeout()), SLOT(tryToConnect()));
|
||||
d->m_connectionTimer.setInterval(200);
|
||||
connect(&d->m_connectionTimer, SIGNAL(timeout()), SLOT(tryToConnect()));
|
||||
}
|
||||
|
||||
QmlProfilerTool::~QmlProfilerTool()
|
||||
@@ -247,12 +247,12 @@ QWidget *QmlProfilerTool::createControlWidget()
|
||||
d->m_recordButton->setChecked(true);
|
||||
layout->addWidget(d->m_recordButton);
|
||||
|
||||
QLabel *timeLabel = new QLabel(tr("elapsed: 0 s"));
|
||||
QLabel *timeLabel = new QLabel(QLatin1Char(' ') + tr("Elapsed: 0 s"));
|
||||
QPalette palette = timeLabel->palette();
|
||||
palette.setColor(QPalette::WindowText, Qt::white);
|
||||
timeLabel->setPalette(palette);
|
||||
|
||||
connect(this,SIGNAL(setTimeLabel(QString)),timeLabel,SLOT(setText(QString)));
|
||||
connect(this, SIGNAL(setTimeLabel(QString)), timeLabel, SLOT(setText(QString)));
|
||||
layout->addWidget(timeLabel);
|
||||
toolbarWidget->setLayout(layout);
|
||||
|
||||
|
||||
@@ -65,12 +65,6 @@ AnalyzerStartParameters localStartParameters(ProjectExplorer::RunConfiguration *
|
||||
QmlProjectAnalyzerRunControlFactory::QmlProjectAnalyzerRunControlFactory(QObject *parent)
|
||||
: IRunControlFactory(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QmlProjectAnalyzerRunControlFactory::~QmlProjectAnalyzerRunControlFactory()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool QmlProjectAnalyzerRunControlFactory::canRun(RunConfiguration *runConfiguration, const QString &mode) const
|
||||
@@ -82,8 +76,8 @@ bool QmlProjectAnalyzerRunControlFactory::canRun(RunConfiguration *runConfigurat
|
||||
|
||||
RunControl *QmlProjectAnalyzerRunControlFactory::create(RunConfiguration *runConfiguration, const QString &mode)
|
||||
{
|
||||
if (!qobject_cast<QmlProjectManager::QmlProjectRunConfiguration *>(runConfiguration) ||
|
||||
mode != Constants::MODE_ANALYZE) {
|
||||
if (!qobject_cast<QmlProjectManager::QmlProjectRunConfiguration *>(runConfiguration)
|
||||
|| mode != Constants::MODE_ANALYZE) {
|
||||
return 0;
|
||||
}
|
||||
const AnalyzerStartParameters sp = localStartParameters(runConfiguration);
|
||||
@@ -109,7 +103,7 @@ IRunConfigurationAspect *QmlProjectAnalyzerRunControlFactory::createRunConfigura
|
||||
|
||||
RunConfigWidget *QmlProjectAnalyzerRunControlFactory::createConfigurationWidget(RunConfiguration *runConfiguration)
|
||||
{
|
||||
QmlProjectManager::QmlProjectRunConfiguration *localRc =
|
||||
QmlProjectManager::QmlProjectRunConfiguration *localRc =
|
||||
qobject_cast<QmlProjectManager::QmlProjectRunConfiguration *>(runConfiguration);
|
||||
if (!localRc)
|
||||
return 0;
|
||||
@@ -121,5 +115,4 @@ RunConfigWidget *QmlProjectAnalyzerRunControlFactory::createConfigurationWidget(
|
||||
Analyzer::AnalyzerRunConfigWidget *ret = new Analyzer::AnalyzerRunConfigWidget;
|
||||
ret->setRunConfiguration(runConfiguration);
|
||||
return ret;
|
||||
// return 0;
|
||||
}
|
||||
|
||||
@@ -44,13 +44,13 @@ namespace Internal {
|
||||
class QmlProjectAnalyzerRunControlFactory : public ProjectExplorer::IRunControlFactory
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
typedef ProjectExplorer::RunConfiguration RunConfiguration;
|
||||
|
||||
QmlProjectAnalyzerRunControlFactory(QObject *parent = 0);
|
||||
~QmlProjectAnalyzerRunControlFactory();
|
||||
|
||||
// virtuals from IRunControlFactory
|
||||
// IRunControlFactory implementation
|
||||
bool canRun(RunConfiguration *runConfiguration, const QString &mode) const;
|
||||
ProjectExplorer::RunControl *create(RunConfiguration *runConfiguration, const QString &mode);
|
||||
Analyzer::AnalyzerRunControl *create(const Analyzer::AnalyzerStartParameters &sp, RunConfiguration *runConfiguration = 0);
|
||||
|
||||
@@ -33,6 +33,8 @@
|
||||
|
||||
#include "tracewindow.h"
|
||||
|
||||
#include "qmlprofilerplugin.h"
|
||||
|
||||
#include <QtCore/qdebug.h>
|
||||
#include <QtCore/qstringlist.h>
|
||||
#include <QtCore/qdatastream.h>
|
||||
@@ -50,11 +52,7 @@
|
||||
#include <QtDeclarative/qdeclarativecontext.h>
|
||||
#include <QtDeclarative/qdeclarative.h>
|
||||
|
||||
#include "qmlprofilerplugin.h"
|
||||
//#include <jsdebuggeragent.h>
|
||||
//#include <qdeclarativeviewobserver.h>
|
||||
|
||||
#define GAP_TIME 150
|
||||
static const int GAP_TIME = 150;
|
||||
|
||||
using QmlJsDebugClient::QDeclarativeDebugClient;
|
||||
|
||||
@@ -72,7 +70,7 @@ struct Location
|
||||
class TracePlugin : public QDeclarativeDebugClient
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool recording READ recording WRITE setRecording NOTIFY recordingChanged)
|
||||
Q_PROPERTY(bool recording READ isRecording WRITE setRecording NOTIFY recordingChanged)
|
||||
|
||||
public:
|
||||
TracePlugin(QDeclarativeDebugConnection *client);
|
||||
@@ -106,10 +104,7 @@ public:
|
||||
MaximumRangeType
|
||||
};
|
||||
|
||||
bool recording() const
|
||||
{
|
||||
return m_recording;
|
||||
}
|
||||
bool isRecording() const { return m_recording; }
|
||||
|
||||
public slots:
|
||||
void setRecording(bool);
|
||||
@@ -133,7 +128,6 @@ protected:
|
||||
virtual void messageReceived(const QByteArray &);
|
||||
|
||||
private:
|
||||
|
||||
qint64 m_inProgressRanges;
|
||||
QStack<qint64> m_rangeStartTimes[MaximumRangeType];
|
||||
QStack<QStringList> m_rangeDatas[MaximumRangeType];
|
||||
@@ -143,13 +137,9 @@ private:
|
||||
bool m_recording;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace QmlProfiler
|
||||
|
||||
using namespace QmlProfiler::Internal;
|
||||
|
||||
TracePlugin::TracePlugin(QDeclarativeDebugConnection *client)
|
||||
: QDeclarativeDebugClient(QLatin1String("CanvasFrameRate"), client), m_inProgressRanges(0), m_maximumTime(0), m_recording(false)
|
||||
: QDeclarativeDebugClient(QLatin1String("CanvasFrameRate"), client),
|
||||
m_inProgressRanges(0), m_maximumTime(0), m_recording(false)
|
||||
{
|
||||
::memset(m_rangeCount, 0, MaximumRangeType * sizeof(int));
|
||||
}
|
||||
@@ -268,7 +258,7 @@ void TracePlugin::messageReceived(const QByteArray &data)
|
||||
}
|
||||
|
||||
TraceWindow::TraceWindow(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
setObjectName(tr("QML Performance Monitor"));
|
||||
|
||||
@@ -340,7 +330,11 @@ void TraceWindow::setRecording(bool recording)
|
||||
|
||||
bool TraceWindow::isRecording() const
|
||||
{
|
||||
return (m_plugin.data()->recording());
|
||||
return m_plugin.data()->isRecording();
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace QmlProfiler
|
||||
|
||||
|
||||
#include "tracewindow.moc"
|
||||
|
||||
Reference in New Issue
Block a user