History

Added script timers performance debugging

ksuprynowicz committed 3 years ago

Commit b554fc71 parent faf9b753 files · +15 −0Browse files

Showing the changes to libraries/script-engine/src/ScriptManager.cpp (1 of 3 files). Show all

Unified · Split

libraries/script-engine/src/ScriptManager.cpp+10−0
@@ -1049,6 +1049,14 @@ void ScriptManager::timerFired() { · 1048 unmodified lines
10491049 return; // bail early
10501050 }
10511051
1052+ _timerCallCounter++;
1053+ if (_timerCallCounter % 100 == 0) {
1054+ qDebug() << "Script engine: " << _engine->manager()->getFilename()
1055+ << "timer call count: " << _timerCallCounter << " total time: " << _totalTimeInTimerEvents_s;
1056+ }
1057+ QElapsedTimer callTimer;
1058+ callTimer.start();
1059+
10521060 QTimer* callingTimer = reinterpret_cast<QTimer*>(sender());
10531061 CallbackData timerData = _timerFunctionMap.value(callingTimer);
10541062
@@ -1069,6 +1077,8 @@ void ScriptManager::timerFired() { · 14 unmodified lines
10691077 } else {
10701078 qCWarning(scriptengine) << "timerFired -- invalid function" << timerData.function.toVariant().toString();
10711079 }
1080+
1081+ _totalTimeInTimerEvents_s += callTimer.elapsed() / 1000.0;
10721082 }
10731083
10741084 QTimer* ScriptManager::setupTimerWithInterval(const ScriptValue& function, int intervalMS, bool isSingleShot) {