diff options
author | Alexis Menard <alexis.menard@nokia.com> | 2010-01-07 15:13:14 (GMT) |
---|---|---|
committer | Alexis Menard <alexis.menard@nokia.com> | 2010-01-07 15:18:15 (GMT) |
commit | 6026436f0de6020252410c021e0745a22599b159 (patch) | |
tree | 0ee98699f583abb78768178841522f6930ae4ba3 /tests/benchmarks/qgraphicsscene | |
parent | f4e633af484b1016bed5935e29f99a49dc403e3c (diff) | |
download | Qt-6026436f0de6020252410c021e0745a22599b159.zip Qt-6026436f0de6020252410c021e0745a22599b159.tar.gz Qt-6026436f0de6020252410c021e0745a22599b159.tar.bz2 |
Fix performance regression in _q_polishItems.
QSet is a hash internally, using Iterator::begin while erasing elements
inside the set might create holes and then the complexity increase.
We now use the return value of erase (the next element) so the
complexity is linear.
For those who create/delete item in the polish event (BAD), _q_polishItem
might be slower than the normal call.
Task-number:QTBUG-6958
Reviewed-by:olivier
Diffstat (limited to 'tests/benchmarks/qgraphicsscene')
-rw-r--r-- | tests/benchmarks/qgraphicsscene/tst_qgraphicsscene.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/benchmarks/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/benchmarks/qgraphicsscene/tst_qgraphicsscene.cpp index 1944219..53fd9b6 100644 --- a/tests/benchmarks/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/benchmarks/qgraphicsscene/tst_qgraphicsscene.cpp @@ -64,6 +64,7 @@ private slots: void addItem(); void itemAt_data(); void itemAt(); + void initialShow(); }; tst_QGraphicsScene::tst_QGraphicsScene() @@ -227,5 +228,21 @@ void tst_QGraphicsScene::itemAt() qApp->processEvents(); } +void tst_QGraphicsScene::initialShow() +{ + QGraphicsScene scene; + + QBENCHMARK { + for (int y = 0; y < 30000; ++y) { + QGraphicsRectItem *item = new QGraphicsRectItem(0, 0, 50, 50); + item->setPos((y/2) * item->rect().width(), (y/2) * item->rect().height()); + scene.addItem(item); + } + scene.itemAt(0, 0); // triggers indexing + //This call polish the items so we bench their processing too. + qApp->processEvents(); + } +} + QTEST_MAIN(tst_QGraphicsScene) #include "tst_qgraphicsscene.moc" |