diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2016-05-24 11:58:07 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2016-05-27 09:31:08 +0000 |
commit | 515efdb8a65dc8ba22a56a02ee6d7056f39619cb (patch) | |
tree | d984f8725ca2e9b0663b33378e5fe1d13b64fa8e /src/qml/jsruntime/qv4profiling_p.h | |
parent | 777aac3005feb01aed21df9e135d5470182bc6ce (diff) |
QmlProfiler: Send RangeData and RangeLocation only once per type
This saves time when serializing the data to be sent.
Change-Id: Ic8c534d55445934a64dd253273099194b27d98af
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4profiling_p.h')
-rw-r--r-- | src/qml/jsruntime/qv4profiling_p.h | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/src/qml/jsruntime/qv4profiling_p.h b/src/qml/jsruntime/qv4profiling_p.h index bb128b7cf3..01fdf2951e 100644 --- a/src/qml/jsruntime/qv4profiling_p.h +++ b/src/qml/jsruntime/qv4profiling_p.h @@ -134,6 +134,11 @@ public: return *this; } + Function *function() const + { + return m_function; + } + FunctionLocation resolveLocation() const; FunctionCallProperties properties() const; @@ -165,6 +170,46 @@ class Q_QML_EXPORT Profiler : public QObject { Q_OBJECT Q_DISABLE_COPY(Profiler) public: + struct SentMarker { + SentMarker() : m_function(nullptr) {} + + SentMarker(const SentMarker &other) : m_function(other.m_function) + { + if (m_function) + m_function->compilationUnit->addref(); + } + + ~SentMarker() + { + if (m_function) + m_function->compilationUnit->release(); + } + + SentMarker &operator=(const SentMarker &other) + { + if (&other != this) { + if (m_function) + m_function->compilationUnit->release(); + m_function = other.m_function; + m_function->compilationUnit->addref(); + } + return *this; + } + + void setFunction(Function *function) + { + Q_ASSERT(m_function == nullptr); + m_function = function; + m_function->compilationUnit->addref(); + } + + bool isValid() const + { return m_function != nullptr; } + + private: + Function *m_function; + }; + Profiler(QV4::ExecutionEngine *engine); size_t trackAlloc(size_t size, MemoryType type) @@ -186,7 +231,7 @@ public: public slots: void stopProfiling(); void startProfiling(quint64 features); - void reportData(); + void reportData(bool trackLocations); void setTimer(const QElapsedTimer &timer) { m_timer = timer; } signals: @@ -199,6 +244,7 @@ private: QElapsedTimer m_timer; QVector<FunctionCall> m_data; QVector<MemoryAllocationProperties> m_memory_data; + QHash<quintptr, SentMarker> m_sentLocations; friend class FunctionCallProfiler; }; @@ -237,6 +283,7 @@ Q_DECLARE_TYPEINFO(QV4::Profiling::MemoryAllocationProperties, Q_MOVABLE_TYPE); Q_DECLARE_TYPEINFO(QV4::Profiling::FunctionCallProperties, Q_MOVABLE_TYPE); Q_DECLARE_TYPEINFO(QV4::Profiling::FunctionCall, Q_MOVABLE_TYPE); Q_DECLARE_TYPEINFO(QV4::Profiling::FunctionLocation, Q_MOVABLE_TYPE); +Q_DECLARE_TYPEINFO(QV4::Profiling::Profiler::SentMarker, Q_MOVABLE_TYPE); QT_END_NAMESPACE Q_DECLARE_METATYPE(QV4::Profiling::FunctionLocationHash) |