Added signal time and call count debugging

This commit is contained in:
ksuprynowicz 2023-02-20 19:49:27 +01:00
parent 1ad1aee11f
commit faf9b75487
2 changed files with 15 additions and 1 deletions

View file

@ -13,6 +13,7 @@
#include "ScriptObjectV8Proxy.h"
#include <QElapsedTimer>
#include <QtCore/QList>
#include <QtCore/QSharedPointer>
@ -1161,7 +1162,15 @@ int ScriptSignalV8Proxy::qt_metacall(QMetaObject::Call call, int id, void** argu
if (id != 0 || call != QMetaObject::InvokeMetaMethod) {
return id;
}
_callCounter++;
if (_callCounter % 10 == 0) {
qDebug() << "Script engine: " << _engine->manager()->getFilename() << " Signal proxy " << fullName()
<< " call count: " << _callCounter << " total time: " << _totalCallTime_s;
}
QElapsedTimer callTimer;
callTimer.start();
auto isolate = _engine->getIsolate();
v8::Locker locker(isolate);
v8::Isolate::Scope isolateScope(isolate);
@ -1251,6 +1260,8 @@ int ScriptSignalV8Proxy::qt_metacall(QMetaObject::Call call, int id, void** argu
}
});
_totalCallTime_s += callTimer.elapsed() / 1000.0;
return -1;
}

View file

@ -257,6 +257,9 @@ private: // storage
bool _isConnected{ false };
// Context in which it was created
v8::UniquePersistent<v8::Context> _v8Context;
// Call counter for debugging purposes. It can be used to determine which signals are overwhelming script engine.
int _callCounter{0};
float _totalCallTime_s{ 0.0 };
Q_DISABLE_COPY(ScriptSignalV8Proxy)
};