From 1de6e7b8e0ee465f642e1b2f5a14611e52a7e8c2 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 3 Sep 2014 19:28:35 +0200 Subject: Select specific features to be recorded when profiling QML Some features, like the memory profiler, create huge amounts of data. Often enough, we're not actually interested in all the data available from the profiler and collecting it all can lead to excessive memory consumption. This change enables us to optionally turn various aspects of QML profiling off. Task-number: QTBUG-41118 Change-Id: I7bb223414e24eb903124ffa6e0896af6ce974e49 Reviewed-by: Gunnar Sletta --- src/qml/jsruntime/qv4profiling.cpp | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) (limited to 'src/qml/jsruntime/qv4profiling.cpp') diff --git a/src/qml/jsruntime/qv4profiling.cpp b/src/qml/jsruntime/qv4profiling.cpp index 693af854da..f1bd1d55d9 100644 --- a/src/qml/jsruntime/qv4profiling.cpp +++ b/src/qml/jsruntime/qv4profiling.cpp @@ -53,7 +53,7 @@ FunctionCallProperties FunctionCall::resolve() const } -Profiler::Profiler(QV4::ExecutionEngine *engine) : enabled(false), m_engine(engine) +Profiler::Profiler(QV4::ExecutionEngine *engine) : featuresEnabled(0), m_engine(engine) { static int metatype = qRegisterMetaType >(); static int metatype2 = qRegisterMetaType >(); @@ -69,7 +69,7 @@ struct FunctionCallComparator { void Profiler::stopProfiling() { - enabled = false; + featuresEnabled = 0; reportData(); } @@ -85,27 +85,29 @@ void Profiler::reportData() emit dataReady(resolved, m_memory_data); } -void Profiler::startProfiling() +void Profiler::startProfiling(quint64 features) { - if (!enabled) { + if (featuresEnabled == 0) { m_data.clear(); m_memory_data.clear(); - qint64 timestamp = m_timer.nsecsElapsed(); - MemoryAllocationProperties heap = {timestamp, - (qint64)m_engine->memoryManager->getAllocatedMem(), - HeapPage}; - m_memory_data.append(heap); - MemoryAllocationProperties small = {timestamp, - (qint64)m_engine->memoryManager->getUsedMem(), - SmallItem}; - m_memory_data.append(small); - MemoryAllocationProperties large = {timestamp, - (qint64)m_engine->memoryManager->getLargeItemsMem(), - LargeItem}; - m_memory_data.append(large); + if (features & (1 << FeatureMemoryAllocation)) { + qint64 timestamp = m_timer.nsecsElapsed(); + MemoryAllocationProperties heap = {timestamp, + (qint64)m_engine->memoryManager->getAllocatedMem(), + HeapPage}; + m_memory_data.append(heap); + MemoryAllocationProperties small = {timestamp, + (qint64)m_engine->memoryManager->getUsedMem(), + SmallItem}; + m_memory_data.append(small); + MemoryAllocationProperties large = {timestamp, + (qint64)m_engine->memoryManager->getLargeItemsMem(), + LargeItem}; + m_memory_data.append(large); + } - enabled = true; + featuresEnabled = features; } } -- cgit v1.2.3