aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/debugger/qqmlprofilerservice_p.h
diff options
context:
space:
mode:
authorMatthew Vogt <matthew.vogt@nokia.com>2012-03-05 11:39:24 +1000
committerMatthew Vogt <matthew.vogt@nokia.com>2012-03-05 11:39:54 +1000
commit0284817d6cd7e17afa8da26ee6e9199100754446 (patch)
treec351d55d5a606c81c72e481f846b9b9e2603c883 /src/qml/debugger/qqmlprofilerservice_p.h
parent377eb94eb19dafeca20d12bc6b624f1779fae514 (diff)
parent36bd7f616f37f5f60e59bce1f0d8970248d627de (diff)
Merge master <-> api_changes
Diffstat (limited to 'src/qml/debugger/qqmlprofilerservice_p.h')
-rw-r--r--src/qml/debugger/qqmlprofilerservice_p.h158
1 files changed, 139 insertions, 19 deletions
diff --git a/src/qml/debugger/qqmlprofilerservice_p.h b/src/qml/debugger/qqmlprofilerservice_p.h
index a74ce10c74..7a708456ba 100644
--- a/src/qml/debugger/qqmlprofilerservice_p.h
+++ b/src/qml/debugger/qqmlprofilerservice_p.h
@@ -54,9 +54,11 @@
//
#include <private/qqmldebugservice_p.h>
+#include <QtQml/qtqmlglobal.h>
#include <QtCore/qelapsedtimer.h>
#include <QtCore/qmutex.h>
#include <QtCore/qvector.h>
+#include <QtCore/qstringbuilder.h>
QT_BEGIN_HEADER
@@ -83,13 +85,6 @@ Q_DECLARE_TYPEINFO(QQmlProfilerData, Q_MOVABLE_TYPE);
class QUrl;
class QQmlEngine;
-// RAII
-class Q_AUTOTEST_EXPORT QQmlBindingProfiler {
-public:
- QQmlBindingProfiler(const QString &url, int line, int column);
- ~QQmlBindingProfiler();
- void addDetail(const QString &details);
-};
class Q_QML_EXPORT QQmlProfilerService : public QQmlDebugService
{
@@ -132,12 +127,6 @@ public:
static bool stopProfiling();
static void sendStartedProfilingMessage();
static void addEvent(EventType);
- static void startRange(RangeType);
- static void rangeData(RangeType, const QString &);
- static void rangeData(RangeType, const QUrl &);
- static void rangeLocation(RangeType, const QString &, int, int);
- static void rangeLocation(RangeType, const QUrl &, int, int);
- static void endRange(RangeType);
static void animationFrame(qint64);
static void sendProfilingData();
@@ -154,14 +143,16 @@ private:
bool stopProfilingImpl();
void sendStartedProfilingMessageImpl();
void addEventImpl(EventType);
- void startRangeImpl(RangeType);
- void rangeDataImpl(RangeType, const QString &);
- void rangeDataImpl(RangeType, const QUrl &);
- void rangeLocationImpl(RangeType, const QString &, int, int);
- void rangeLocationImpl(RangeType, const QUrl &, int, int);
- void endRangeImpl(RangeType);
void animationFrameImpl(qint64);
+ void startRange(RangeType);
+ void rangeData(RangeType, const QString &);
+ void rangeData(RangeType, const QUrl &);
+ void rangeLocation(RangeType, const QString &, int, int);
+ void rangeLocation(RangeType, const QUrl &, int, int);
+ void endRange(RangeType);
+
+
bool profilingEnabled();
void setProfilingEnabled(bool enable);
void sendMessages();
@@ -173,6 +164,135 @@ private:
bool m_messageReceived;
QVector<QQmlProfilerData> m_data;
QMutex m_mutex;
+
+ static QQmlProfilerService *instance;
+
+ friend struct QQmlBindingProfiler;
+ friend struct QQmlHandlingSignalProfiler;
+ friend struct QQmlObjectCreatingProfiler;
+ friend struct QQmlCompilingProfiler;
+};
+
+//
+// RAII helper structs
+//
+
+struct QQmlBindingProfiler {
+ QQmlBindingProfiler(const QString &url, int line, int column)
+ {
+ QQmlProfilerService *instance = QQmlProfilerService::instance;
+ enabled = instance ? instance->profilingEnabled() : false;
+ if (enabled) {
+ instance->startRange(QQmlProfilerService::Binding);
+ instance->rangeLocation(QQmlProfilerService::Binding, url, line, column);
+ }
+ }
+
+ ~QQmlBindingProfiler()
+ {
+ if (enabled)
+ QQmlProfilerService::instance->endRange(QQmlProfilerService::Binding);
+ }
+
+ void addDetail(const QString &details)
+ {
+ if (enabled)
+ QQmlProfilerService::instance->rangeData(QQmlProfilerService::Binding,
+ details);
+ }
+\
+ bool enabled;
+};
+
+struct QQmlHandlingSignalProfiler {
+ QQmlHandlingSignalProfiler()
+ {
+ enabled = QQmlProfilerService::instance
+ ? QQmlProfilerService::instance->profilingEnabled() : false;
+ if (enabled) {
+ QQmlProfilerService::instance->startRange(
+ QQmlProfilerService::HandlingSignal);
+ }
+ }
+
+ void setSignalInfo(const QString &name, const QString &expression)
+ {
+ if (enabled)
+ QQmlProfilerService::instance->rangeData(
+ QQmlProfilerService::HandlingSignal,
+ name % QLatin1String(": ") % expression);
+ }
+
+ void setLocation(const QString &file, int line, int column)
+ {
+ if (enabled)
+ QQmlProfilerService::instance->rangeLocation(
+ QQmlProfilerService::HandlingSignal, file, line, column);
+ }
+
+ ~QQmlHandlingSignalProfiler()
+ {
+ if (enabled)
+ QQmlProfilerService::instance->endRange(
+ QQmlProfilerService::HandlingSignal);
+ }
+
+ bool enabled;
+};
+
+struct QQmlObjectCreatingProfiler {
+ QQmlObjectCreatingProfiler()
+ {
+ QQmlProfilerService *instance = QQmlProfilerService::instance;
+ enabled = instance ?
+ instance->profilingEnabled() : false;
+ if (enabled)
+ instance->startRange(QQmlProfilerService::Creating);
+ }
+
+ void setTypeName(const QString &typeName)
+ {
+ if (enabled)
+ QQmlProfilerService::instance->rangeData(
+ QQmlProfilerService::Creating, typeName);
+ }
+
+ void setLocation(const QUrl &url, int line, int column)
+ {
+ if (enabled)
+ QQmlProfilerService::instance->rangeLocation(
+ QQmlProfilerService::Creating, url, line, column);
+ }
+
+ ~QQmlObjectCreatingProfiler()
+ {
+ if (enabled)
+ QQmlProfilerService::instance->endRange(QQmlProfilerService::Creating);
+ }
+
+ bool enabled;
+};
+
+struct QQmlCompilingProfiler {
+ QQmlCompilingProfiler(const QString &name)
+ {
+ QQmlProfilerService *instance = QQmlProfilerService::instance;
+ enabled = instance ?
+ instance->profilingEnabled() : false;
+ if (enabled) {
+ instance->startRange(QQmlProfilerService::Compiling);
+ instance->rangeLocation(QQmlProfilerService::Compiling, name, 1, 1);
+ instance->rangeData(QQmlProfilerService::Compiling, name);
+ }
+ }
+
+ ~QQmlCompilingProfiler()
+ {
+ if (enabled)
+ QQmlProfilerService::instance->endRange(QQmlProfilerService::Compiling);
+ }
+
+ bool enabled;
};
QT_END_NAMESPACE