diff options
author | Andreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com> | 2009-08-05 06:16:59 (GMT) |
---|---|---|
committer | Andreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com> | 2009-08-05 06:16:59 (GMT) |
commit | b0470cd7553d26e73929bf9719eea9f49aeb6824 (patch) | |
tree | 015694f56911c158fbbf7cee176570503e1ec3f6 /tests/benchmarks | |
parent | bedfccd293740b00b7cc9f212c119433a4d82d12 (diff) | |
download | Qt-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.pro | 1 | ||||
-rw-r--r-- | tests/benchmarks/qgraphicsitem/tst_qgraphicsitem.cpp | 26 |
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 = ▭ + 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"); |