summaryrefslogtreecommitdiffstats
path: root/tests/benchmarks
diff options
context:
space:
mode:
authorAndreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com>2009-08-05 06:16:59 (GMT)
committerAndreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com>2009-08-05 06:16:59 (GMT)
commitb0470cd7553d26e73929bf9719eea9f49aeb6824 (patch)
tree015694f56911c158fbbf7cee176570503e1ec3f6 /tests/benchmarks
parentbedfccd293740b00b7cc9f212c119433a4d82d12 (diff)
downloadQt-b0470cd7553d26e73929bf9719eea9f49aeb6824.zip
Qt-b0470cd7553d26e73929bf9719eea9f49aeb6824.tar.gz
Qt-b0470cd7553d26e73929bf9719eea9f49aeb6824.tar.bz2
Add benchmarks for QGraphicsItem::setParenItem().
Ensure we test simple and deep constructs of setParentItem(). These benchmarks don't cover slowness in ancestor flag updating. QVariant is already identified as a contributor to this slowness, as is updating of the depth value (a deep tree crawl). Reviewed-by: Aaron Kennedy
Diffstat (limited to 'tests/benchmarks')
-rw-r--r--tests/benchmarks/qgraphicsitem/qgraphicsitem.pro1
-rw-r--r--tests/benchmarks/qgraphicsitem/tst_qgraphicsitem.cpp26
2 files changed, 26 insertions, 1 deletions
diff --git a/tests/benchmarks/qgraphicsitem/qgraphicsitem.pro b/tests/benchmarks/qgraphicsitem/qgraphicsitem.pro
index c8fc07b..726bb96 100644
--- a/tests/benchmarks/qgraphicsitem/qgraphicsitem.pro
+++ b/tests/benchmarks/qgraphicsitem/qgraphicsitem.pro
@@ -3,4 +3,3 @@ TEMPLATE = app
TARGET = tst_qgraphicsitem
SOURCES += tst_qgraphicsitem.cpp
-
diff --git a/tests/benchmarks/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/benchmarks/qgraphicsitem/tst_qgraphicsitem.cpp
index 42f2e6b..62a5b5c 100644
--- a/tests/benchmarks/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/benchmarks/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -25,6 +25,8 @@ public slots:
void cleanup();
private slots:
+ void setParentItem();
+ void setParentItem_deep();
void setPos_data();
void setPos();
void setTransform_data();
@@ -52,6 +54,30 @@ void tst_QGraphicsItem::cleanup()
{
}
+void tst_QGraphicsItem::setParentItem()
+{
+ QBENCHMARK {
+ QGraphicsRectItem rect;
+ QGraphicsRectItem *childRect = new QGraphicsRectItem;
+ childRect->setParentItem(&rect);
+ }
+}
+
+void tst_QGraphicsItem::setParentItem_deep()
+{
+ QBENCHMARK {
+ QGraphicsRectItem rect;
+ QGraphicsRectItem *lastRect = &rect;
+ for (int i = 0; i < 10; ++i) {
+ QGraphicsRectItem *childRect = new QGraphicsRectItem;
+ childRect->setParentItem(lastRect);
+ lastRect = childRect;
+ }
+ QGraphicsItem *first = rect.children().first();
+ first->setParentItem(0);
+ }
+}
+
void tst_QGraphicsItem::setPos_data()
{
QTest::addColumn<QPointF>("pos");