summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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 = ▭
+ 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");