From 17c8fa04ce00a332310793b0e21991ab19c74e0d Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 27 Nov 2013 12:58:13 +0100 Subject: Add a stack-based object creation profiler The simple instantiate-in-context way of profiling object creation doesn't work anymore because the VME's contexts don't necessarily map to C++ contexts anymore. The new profiler introduces two stacks of contexts, one for currently running ranges (such as components) and one for ranges that will be revived later to profile componentComplete() and similar things. Task-number: QTCREATORBUG-10631 Change-Id: Idf19b2adf062bc9c185b3bb5ff5229381f577645 Reviewed-by: Ulf Hermann Reviewed-by: Simon Hausmann --- src/qml/debugger/qqmlprofilerservice_p.h | 49 ++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'src/qml/debugger/qqmlprofilerservice_p.h') diff --git a/src/qml/debugger/qqmlprofilerservice_p.h b/src/qml/debugger/qqmlprofilerservice_p.h index 52a1dead09..c2e9eb421a 100644 --- a/src/qml/debugger/qqmlprofilerservice_p.h +++ b/src/qml/debugger/qqmlprofilerservice_p.h @@ -225,6 +225,7 @@ private: friend struct QQmlBindingProfiler; friend struct QQmlHandlingSignalProfiler; + friend struct QQmlVmeProfiler; friend struct QQmlCompilingProfiler; friend struct QQmlPixmapProfiler; }; @@ -298,6 +299,54 @@ struct QQmlCompilingProfiler { bool enabled; }; +struct QQmlVmeProfiler { +public: + const bool enabled; + + struct Data { + Data() : line(0), column(0) {} + QUrl url; + int line; + int column; + QString typeName; + void clear(); + }; + + QQmlVmeProfiler() : + enabled(QQmlProfilerService::instance ? QQmlProfilerService::instance->profilingEnabled() : false), + running(false) + {} + + ~QQmlVmeProfiler() + { + if (enabled) + clear(); + } + + void clear(); + + void start(const QUrl &url, int line, int column, const QString &typeName); + void start(); + void stop(); + + void updateLocation(const QUrl &url, int line, int column); + void updateTypeName(const QString &typeName); + + void pop(); + void push(); + + void background(); + void foreground(); + +private: + void switchRange(); + + Data currentRange; + QStack ranges; + QStack backgroundRanges; + bool running; +}; + struct QQmlPixmapProfiler { QQmlPixmapProfiler() { QQmlProfilerService *instance = QQmlProfilerService::instance; -- cgit v1.2.3