diff options
author | Ulf Hermann <ulf.hermann@digia.com> | 2014-01-07 10:29:45 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-01-22 18:10:12 +0100 |
commit | b287ed4c4dee9d705073badc79cdb0c3e183d19b (patch) | |
tree | 3e2632d2408dc73f44e84831ec71d0d99e3dac2d /src | |
parent | f781d97e141632c646da09888c9612931f7c928b (diff) |
Put calls to QQmlVmeProfiler behind "if (enabled)" macros
The construction of arguments to those calls may be expensive and should
be avoided if we're not really profiling.
Task-number: QTBUG-35315
Change-Id: I558fa4cae6cf532d22193283f1ee2a3b680e2eee
Reviewed-by: Michael Brasser <michael.brasser@live.com>
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/qml/debugger/qqmlprofilerservice_p.h | 46 | ||||
-rw-r--r-- | src/qml/qml/qqmlvme.cpp | 24 |
2 files changed, 38 insertions, 32 deletions
diff --git a/src/qml/debugger/qqmlprofilerservice_p.h b/src/qml/debugger/qqmlprofilerservice_p.h index 85d515c7dd..20c023eb24 100644 --- a/src/qml/debugger/qqmlprofilerservice_p.h +++ b/src/qml/debugger/qqmlprofilerservice_p.h @@ -411,6 +411,12 @@ struct QQmlCompilingProfiler { } }; +#define Q_QML_VME_PROFILE(Method)\ + if (QQmlProfilerService::enabled)\ + Method;\ + else\ + (void)0 + struct QQmlVmeProfiler { public: @@ -427,12 +433,10 @@ public: void clear() { ranges.clear(); - if (QQmlProfilerService::enabled) { - if (running) - QQmlProfilerService::instance->endRange(QQmlProfilerService::Creating); - for (int i = 0; i < backgroundRanges.count(); ++i) { - QQmlProfilerService::instance->endRange(QQmlProfilerService::Creating); - } + if (running) + QQmlProfilerService::instance->endRange(QQmlProfilerService::Creating); + for (int i = 0; i < backgroundRanges.count(); ++i) { + QQmlProfilerService::instance->endRange(QQmlProfilerService::Creating); } backgroundRanges.clear(); running = false; @@ -440,29 +444,25 @@ public: void startBackground(const QString &typeName) { - if (QQmlProfilerService::enabled) { - if (running) { - QQmlProfilerService::instance->endRange(QQmlProfilerService::Creating); - running = false; - } - QQmlProfilerService::instance->startRange(QQmlProfilerService::Creating, typeName); - backgroundRanges.push(typeName); + if (running) { + QQmlProfilerService::instance->endRange(QQmlProfilerService::Creating); + running = false; } + QQmlProfilerService::instance->startRange(QQmlProfilerService::Creating, typeName); + backgroundRanges.push(typeName); } void start(const QString &typeName, const QUrl &url, int line, int column) { - if (QQmlProfilerService::enabled) { - switchRange(); - setCurrentRange(typeName, url, line, column); - QQmlProfilerService::instance->startRange(QQmlProfilerService::Creating, typeName, url, - line, column); - } + switchRange(); + setCurrentRange(typeName, url, line, column); + QQmlProfilerService::instance->startRange(QQmlProfilerService::Creating, typeName, url, + line, column); } void stop() { - if (QQmlProfilerService::enabled && running) { + if (running) { QQmlProfilerService::instance->endRange(QQmlProfilerService::Creating); running = false; } @@ -470,7 +470,7 @@ public: void pop() { - if (QQmlProfilerService::enabled && ranges.count() > 0) { + if (ranges.count() > 0) { switchRange(); currentRange = ranges.pop(); QQmlProfilerService::instance->startRange(QQmlProfilerService::Creating, @@ -481,13 +481,13 @@ public: void push() { - if (QQmlProfilerService::enabled && running) + if (running) ranges.push(currentRange); } void foreground(const QUrl &url, int line, int column) { - if (QQmlProfilerService::enabled && backgroundRanges.count() > 0) { + if (backgroundRanges.count() > 0) { switchRange(); setCurrentRange(backgroundRanges.pop(), url, line, column); QQmlProfilerService::instance->rangeLocation( diff --git a/src/qml/qml/qqmlvme.cpp b/src/qml/qml/qqmlvme.cpp index f5229be7ef..115fcc72d2 100644 --- a/src/qml/qml/qqmlvme.cpp +++ b/src/qml/qml/qqmlvme.cpp @@ -503,7 +503,7 @@ QObject *QQmlVME::run(QList<QQmlError> *errors, const QQmlCompiledData::TypeReference &type = TYPES.at(instr.type); Q_ASSERT(type.component); - profiler.startBackground(type.component->name); + Q_QML_VME_PROFILE(profiler.startBackground(type.component->name)); states.push(State()); @@ -526,7 +526,7 @@ QObject *QQmlVME::run(QList<QQmlError> *errors, QML_END_INSTR(CreateQMLObject) QML_BEGIN_INSTR(CompleteQMLObject) - profiler.foreground(CTXT->url, instr.line, instr.column); + Q_QML_VME_PROFILE(profiler.foreground(CTXT->url, instr.line, instr.column)); QObject *o = objects.top(); Q_ASSERT(o); @@ -570,7 +570,7 @@ QObject *QQmlVME::run(QList<QQmlError> *errors, QML_BEGIN_INSTR(CreateCppObject) const QQmlCompiledData::TypeReference &type = TYPES.at(instr.type); Q_ASSERT(type.type); - profiler.start(type.type->qmlTypeName(), CTXT->url, instr.line, instr.column); + Q_QML_VME_PROFILE(profiler.start(type.type->qmlTypeName(), CTXT->url, instr.line, instr.column)); QObject *o = 0; void *memory = 0; @@ -643,7 +643,7 @@ QObject *QQmlVME::run(QList<QQmlError> *errors, QML_BEGIN_INSTR(CreateSimpleObject) const QQmlCompiledData::TypeReference &ref = TYPES.at(instr.type); - profiler.start(ref.type->qmlTypeName(), CTXT->url, instr.line, instr.column); + Q_QML_VME_PROFILE(profiler.start(ref.type->qmlTypeName(), CTXT->url, instr.line, instr.column)); QObject *o = (QObject *)operator new(instr.typeSize + sizeof(QQmlData)); ::memset(static_cast<void *>(o), 0, instr.typeSize + sizeof(QQmlData)); instr.create(o); @@ -823,7 +823,7 @@ QObject *QQmlVME::run(QList<QQmlError> *errors, QML_END_INSTR(StoreScriptString) QML_BEGIN_INSTR(BeginObject) - profiler.push(); + Q_QML_VME_PROFILE(profiler.push()); QObject *target = objects.top(); QQmlParserStatus *status = reinterpret_cast<QQmlParserStatus *>(reinterpret_cast<char *>(target) + instr.castValue); parserStatus.push(status); @@ -1081,7 +1081,7 @@ normalExit: objects.deallocate(); lists.deallocate(); states.clear(); - profiler.stop(); + Q_QML_VME_PROFILE(profiler.stop()); return rv; } @@ -1119,7 +1119,13 @@ void QQmlVME::reset() states.clear(); rootContext = 0; creationContext = 0; - profiler.clear(); + + // If profiling is switched off during a VME run and then switched back on + // before or during the next run background ranges from the first run will + // be reported in the second run because we don't clear() here. We accept + // that as the collected data will be incomplete anyway and because not + // calling clear() here is benefitial for the non-profiling case. + Q_QML_VME_PROFILE(profiler.clear()); } #ifdef QML_THREADED_VME_INTERPRETER @@ -1179,7 +1185,7 @@ QQmlContextData *QQmlVME::complete(const Interrupt &interrupt) if (componentCompleteEnabled()) { // the qml designer does the component complete later QQmlTrace trace("VME Component Complete"); while (!parserStatus.isEmpty()) { - profiler.pop(); + Q_QML_VME_PROFILE(profiler.pop()); QQmlParserStatus *status = parserStatus.pop(); #ifdef QML_ENABLE_TRACE QQmlData *data = parserStatusData.pop(); @@ -1199,7 +1205,7 @@ QQmlContextData *QQmlVME::complete(const Interrupt &interrupt) return 0; } parserStatus.deallocate(); - profiler.clear(); + Q_QML_VME_PROFILE(profiler.clear()); } { |