aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime
diff options
context:
space:
mode:
Diffstat (limited to 'src/qml/jsruntime')
-rw-r--r--src/qml/jsruntime/qv4profiling.cpp38
-rw-r--r--src/qml/jsruntime/qv4profiling_p.h18
2 files changed, 33 insertions, 23 deletions
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<QList<QV4::Profiling::FunctionCallProperties> >();
static int metatype2 = qRegisterMetaType<QList<QV4::Profiling::MemoryAllocationProperties> >();
@@ -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;
}
}
diff --git a/src/qml/jsruntime/qv4profiling_p.h b/src/qml/jsruntime/qv4profiling_p.h
index f115137c86..8224f8a851 100644
--- a/src/qml/jsruntime/qv4profiling_p.h
+++ b/src/qml/jsruntime/qv4profiling_p.h
@@ -46,6 +46,11 @@ namespace QV4 {
namespace Profiling {
+enum Features {
+ FeatureFunctionCall,
+ FeatureMemoryAllocation
+};
+
enum MemoryType {
HeapPage,
LargeItem,
@@ -106,15 +111,18 @@ private:
};
#define Q_V4_PROFILE_ALLOC(engine, size, type)\
- (engine->profiler && engine->profiler->enabled ?\
+ (engine->profiler &&\
+ (engine->profiler->featuresEnabled & (1 << Profiling::FeatureMemoryAllocation)) ?\
engine->profiler->trackAlloc(size, type) : size)
#define Q_V4_PROFILE_DEALLOC(engine, pointer, size, type) \
- (engine->profiler && engine->profiler->enabled ?\
+ (engine->profiler &&\
+ (engine->profiler->featuresEnabled & (1 << Profiling::FeatureMemoryAllocation)) ?\
engine->profiler->trackDealloc(pointer, size, type) : pointer)
#define Q_V4_PROFILE(engine, ctx, function)\
- ((engine->profiler && engine->profiler->enabled) ?\
+ (engine->profiler &&\
+ (engine->profiler->featuresEnabled & (1 << Profiling::FeatureFunctionCall)) ?\
Profiling::FunctionCallProfiler::profileCall(engine->profiler, ctx, function) :\
function->code(ctx, function->codeData))
@@ -138,11 +146,11 @@ public:
return pointer;
}
- bool enabled;
+ quint64 featuresEnabled;
public slots:
void stopProfiling();
- void startProfiling();
+ void startProfiling(quint64 features);
void reportData();
void setTimer(const QElapsedTimer &timer) { m_timer = timer; }