summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorGabriel de Dietrich <gabriel.dietrich-de@nokia.com>2009-08-20 08:07:00 (GMT)
committerGabriel de Dietrich <gabriel.dietrich-de@nokia.com>2009-08-20 09:53:38 (GMT)
commit909cdf082fd99ce8bdcb99a9db38d09f52d869aa (patch)
treed9908456af5eb6f6e5ae374de8d93f6bcfc819e2 /tests
parent264eb347595cc92a444e3908831d89acef1f05b3 (diff)
downloadQt-909cdf082fd99ce8bdcb99a9db38d09f52d869aa.zip
Qt-909cdf082fd99ce8bdcb99a9db38d09f52d869aa.tar.gz
Qt-909cdf082fd99ce8bdcb99a9db38d09f52d869aa.tar.bz2
Performance issue in QGraphicsItem::addParentItem while building the
scene bottom-up. When adding n items, the depth was computed n² times. Adding lazy computation fixes this performance issue. Reviewed-by: Andreas
Diffstat (limited to 'tests')
-rw-r--r--tests/benchmarks/qgraphicsitem/tst_qgraphicsitem.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/benchmarks/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/benchmarks/qgraphicsitem/tst_qgraphicsitem.cpp
index 923838a..91dd28b 100644
--- a/tests/benchmarks/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/benchmarks/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -61,6 +61,7 @@ public slots:
private slots:
void setParentItem();
void setParentItem_deep();
+ void setParentItem_deep_reversed();
void deleteItemWithManyChildren();
void setPos_data();
void setPos();
@@ -113,6 +114,19 @@ void tst_QGraphicsItem::setParentItem_deep()
}
}
+void tst_QGraphicsItem::setParentItem_deep_reversed()
+{
+ QBENCHMARK {
+ QGraphicsRectItem *lastRect = new QGraphicsRectItem;
+ for (int i = 0; i < 100; ++i) {
+ QGraphicsRectItem *parentRect = new QGraphicsRectItem;
+ lastRect->setParentItem(parentRect);
+ lastRect = parentRect;
+ }
+ delete lastRect;
+ }
+}
+
void tst_QGraphicsItem::deleteItemWithManyChildren()
{
QBENCHMARK {