From kde-optimize Sat Nov 12 10:30:50 2005 From: Olivier Goffart Date: Sat, 12 Nov 2005 10:30:50 +0000 To: kde-optimize Subject: normalized signature of signals/slots Message-Id: <200511121130.57257.ogoffart () kde ! org> X-MARC-Message: https://marc.info/?l=kde-optimize&m=113179145816900 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--===============1946752870==" --===============1946752870== Content-Type: multipart/signed; boundary="nextPart2546644.I41M9Rm9EN"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit --nextPart2546644.I41M9Rm9EN Content-Type: multipart/mixed; boundary="Boundary-01=_cRcdDZofkAq78Um" Content-Transfer-Encoding: 7bit Content-Disposition: inline --Boundary-01=_cRcdDZofkAq78Um Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hello When browsing the Qt code, i saw that Qt first try to connect signals witho= ut=20 normalize the signature, and if it fails, it normalize the slot signature a= nd=20 retry . So using normalized signature in signal slot connection is faster that don't But how much, maybe that's negligible ? After some test (attached) I noticed that the normalized signature is about= =20 twice times faster than the not normalized one=20 (This may i guess be even more in the case of bigger signatures, or class w= ith=20 more signals and slots) Usually, we don't use normalized signature: Less intuitive, and the one=20 KDevelop auto-complete (nice feature btw) is not normalized. Does it make sens to write a script that normalize signatures in the code ? --Boundary-01=_cRcdDZofkAq78Um Content-Type: text/x-c++src; charset="us-ascii"; name="test_signals.cpp" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="test_signals.cpp" #include "test_signals.h" #include #include void Test::someSlot(const QString&,const QString&) {}; int main() { int normalized_time; int cu_time; QTime ti; Test t; ti.start(); for(int f=3D0;f<20000;f++) { QObject::connect(&t,SIGNAL(someSignal(QString,QString)) , &t, SLOT(someSl= ot(QString,QString))); QObject::disconnect(&t,SIGNAL(someSignal(QString,QString)) , &t, SLOT(som= eSlot(QString,QString))); QObject::connect(&t,SIGNAL(someSignal(QString,QString)) , &t, SLOT(someSl= ot(QString,QString))); QObject::disconnect(&t,SIGNAL(someSignal(QString,QString)) , &t, SLOT(som= eSlot(QString,QString))); QObject::connect(&t,SIGNAL(someSignal(QString,QString)) , &t, SLOT(someSl= ot(QString,QString))); QObject::disconnect(&t,SIGNAL(someSignal(QString,QString)) , &t, SLOT(som= eSlot(QString,QString))); } normalized_time=3Dti.elapsed(); std::cout << "normalized: " << normalized_time << "ms\n"; ti.start(); for(int f=3D0;f<20000;f++) { QObject::connect(&t,SIGNAL(someSignal(const QString&, const QString&)) , = &t, SLOT(someSlot(const QString&, const QString&))); QObject::disconnect(&t,SIGNAL(someSignal(const QString&, const QString&))= , &t, SLOT(someSlot(const QString&, const QString&))); QObject::connect(&t,SIGNAL(someSignal(const QString&, const QString&)) , = &t, SLOT(someSlot(const QString&, const QString&))); QObject::disconnect(&t,SIGNAL(someSignal(const QString&, const QString&))= , &t, SLOT(someSlot(const QString&, const QString&))); QObject::connect(&t,SIGNAL(someSignal(const QString&, const QString&)) , = &t, SLOT(someSlot(const QString&, const QString&))); QObject::disconnect(&t,SIGNAL(someSignal(const QString&, const QString&))= , &t, SLOT(someSlot(const QString&, const QString&))); } cu_time=3Dti.elapsed(); std::cout << "usual: " << cu_time << "ms ratio: "<< (double)cu_time/(d= ouble)normalized_time <<"\n"; =09 return 1; } #include "test_signals.moc" --Boundary-01=_cRcdDZofkAq78Um Content-Type: text/x-c++hdr; charset="us-ascii"; name="test_signals.h" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="test_signals.h" #ifndef TTTTT #define TTTTT #include #include class Test : public QObject { Q_OBJECT public slots: #ifndef SALUT void someSlot(const QString& str, const QString &str2); signals: void someSignal(const QString& str, const QString &str2); #endif }; #endif --Boundary-01=_cRcdDZofkAq78Um-- --nextPart2546644.I41M9Rm9EN Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (GNU/Linux) iD8DBQBDdcRhz58lY8jWrL0RAljkAJ40Q3YBK++zvHrz6DOqt0CvFuANxACeLljM pJIDMt+elGKb/fXsgOzTJNI= =FtNZ -----END PGP SIGNATURE----- --nextPart2546644.I41M9Rm9EN-- --===============1946752870== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Kde-optimize mailing list Kde-optimize@kde.org https://mail.kde.org/mailman/listinfo/kde-optimize --===============1946752870==--