diff options
Diffstat (limited to 'tests/benchmarks/qgraphicsitem/tst_qgraphicsitem.cpp')
-rw-r--r-- | tests/benchmarks/qgraphicsitem/tst_qgraphicsitem.cpp | 51 |
1 files changed, 38 insertions, 13 deletions
diff --git a/tests/benchmarks/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/benchmarks/qgraphicsitem/tst_qgraphicsitem.cpp index d072d08..ee27ebe 100644 --- a/tests/benchmarks/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/benchmarks/qgraphicsitem/tst_qgraphicsitem.cpp @@ -25,6 +25,9 @@ public slots: void cleanup(); private slots: + void setParentItem(); + void setParentItem_deep(); + void deleteItemWithManyChildren(); void setPos_data(); void setPos(); void setTransform_data(); @@ -34,7 +37,6 @@ private slots: void shear(); void translate(); void setRotation(); - void setRotationXYZ(); }; tst_QGraphicsItem::tst_QGraphicsItem() @@ -53,6 +55,40 @@ 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::deleteItemWithManyChildren() +{ + QBENCHMARK { + QGraphicsRectItem *rect = new QGraphicsRectItem; + for (int i = 0; i < 1000; ++i) + new QGraphicsRectItem(rect); + delete rect; + } +} + void tst_QGraphicsItem::setPos_data() { QTest::addColumn<QPointF>("pos"); @@ -150,18 +186,7 @@ void tst_QGraphicsItem::setRotation() QGraphicsItem *item = scene.addRect(QRectF(0, 0, 100, 100)); QBENCHMARK { - item->setXRotation(45); - item->transform(); // prevent lazy optimizing - } -} - -void tst_QGraphicsItem::setRotationXYZ() -{ - QGraphicsScene scene; - QGraphicsItem *item = scene.addRect(QRectF(0, 0, 100, 100)); - - QBENCHMARK { - item->setRotation(45, 45, 45); + item->setRotation(45); item->transform(); // prevent lazy optimizing } } |