path: root/tests/benchmarks
diff options
authorKent Hansen <>2012-06-25 20:19:11 +0200
committerQt by Nokia <>2012-06-28 14:44:20 +0200
commitd359b0af2b93aeb9c22714be1cec881417650ed8 (patch)
treeedc793d9197500d094c5ee9a01ba3ce252b36c5a /tests/benchmarks
parent26c85a5f79875a25367527462e8d0864021078ab (diff)
Call QObject::disconnectNotify() when receiver is destroyed
Store the signal index in QObjectPrivate::Connection, thereby making it available in "implicit" disconnect contexts (i.e., receiver deletion). This change does not cause the size of QObjectPrivate::Connection to grow (still 40 bytes on 32-bit Linux, 72 bytes on 64-bit Mac). Valgrinding the new benchmark indicates that the percentage of the time spent in the QObject destructor increased from 7.8% to 8.4% on ia32, for that particular stress test; the increase is the combined cost of calling metaObject(), QMetaObjectPrivate::signal(), and disconnectNotify() for one connection. In practice, the measured wallclock time increased by about 3ms for a 500ms run (which repeatedly constructs, connects, and destroys an object). Task-number: QTBUG-4844 Change-Id: I1beb01c753f31542fc0acb62edb4c6d165fcc5b4 Reviewed-by: Olivier Goffart <> Reviewed-by: Bradley T. Hughes <>
Diffstat (limited to 'tests/benchmarks')
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/benchmarks/corelib/kernel/qobject/main.cpp b/tests/benchmarks/corelib/kernel/qobject/main.cpp
index a5a26c1b2a..90912d460c 100644
--- a/tests/benchmarks/corelib/kernel/qobject/main.cpp
+++ b/tests/benchmarks/corelib/kernel/qobject/main.cpp
@@ -61,6 +61,7 @@ private slots:
void dynamic_property_benchmark();
void connect_disconnect_benchmark_data();
void connect_disconnect_benchmark();
+ void receiver_destroyed_benchmark();
struct Functor {
@@ -236,6 +237,15 @@ void QObjectBenchmark::connect_disconnect_benchmark()
+void QObjectBenchmark::receiver_destroyed_benchmark()
+ Object sender;
+ Object receiver;
+ QObject::connect(&sender, &Object::signal0, &receiver, &Object::slot0);
+ }
#include "main.moc"