[Development] Automatic signal-slot statistics
Olivier Goffart
olivier at woboq.com
Wed Aug 8 07:15:02 CEST 2018
On 2018-08-08 06:53, Taras Kushnir wrote:
> Hello
>
> I’ve been refactoring giant pieces (like 50-60%) of one project's codebase and I’m concerned about validity/quality of the result. Except different kinds of tests I’m thinking about statistical metrics one of which would be to get a feel how Qt-specific parts of the project have changes.
>
> Is there any way to produce statistics which signals got fired and how many times (+ the same for slots) automatically during any application runtime?
> (“any" way except of patching and recompiling Qt framework itself)
There is a way:
There is some exported private API from qobject_p.h that you can trivially
re-declare in your project:
struct QSignalSpyCallbackSet
{
typedef void (*BeginCallback)(QObject *caller, int signal_or_method_index,
void **argv);
typedef void (*EndCallback)(QObject *caller, int signal_or_method_index);
BeginCallback signal_begin_callback,
slot_begin_callback;
EndCallback signal_end_callback,
slot_end_callback;
};
void Q_CORE_EXPORT qt_register_signal_spy_callbacks(const QSignalSpyCallbackSet
&callback_set);
extern QSignalSpyCallbackSet Q_CORE_EXPORT qt_signal_spy_callback_set;
https://code.woboq.org/qt5/qtbase/src/corelib/kernel/qobject_p.h.html#73
All you need to do is to call qt_register_signal_spy_callbacks to register the
signal_begin_callback, and this will be called everytime a signal is emited. So
you can gather some statistics from that.
--
Olivier
Woboq - Qt services and support - https://woboq.com - https://code.woboq.org
More information about the Development
mailing list