From ac523359aa630c05df21d4c09970cb0b89a5b05f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Wed, 17 Feb 2010 15:21:46 +0100 Subject: Stabilize QGraphicsItem benchmarks. The benchmark must report stable numbers in order to be useful. E.g. we can not accept instability of +-20% between each run (with the same configuration in the same environment). --- .../qgraphicsitem/tst_qgraphicsitem.cpp | 30 +++++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/tests/benchmarks/gui/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/benchmarks/gui/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp index ac51072..d452593 100644 --- a/tests/benchmarks/gui/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/benchmarks/gui/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp @@ -55,6 +55,7 @@ public: virtual ~tst_QGraphicsItem(); public slots: + void initTestCase(); void init(); void cleanup(); @@ -82,8 +83,23 @@ tst_QGraphicsItem::~tst_QGraphicsItem() { } +static inline void processEvents() +{ + QApplication::flush(); + QApplication::processEvents(); + QApplication::processEvents(); +} + +void tst_QGraphicsItem::initTestCase() +{ + QApplication::flush(); + QTest::qWait(1500); + processEvents(); +} + void tst_QGraphicsItem::init() { + processEvents(); } void tst_QGraphicsItem::cleanup() @@ -152,10 +168,10 @@ void tst_QGraphicsItem::setPos() QGraphicsScene scene; QGraphicsRectItem *rect = scene.addRect(QRectF(0, 0, 100, 100)); + processEvents(); QBENCHMARK { rect->setPos(10, 10); - rect->transform(); // prevent lazy optimizing } } @@ -177,10 +193,10 @@ void tst_QGraphicsItem::setTransform() QGraphicsScene scene; QGraphicsRectItem *item = scene.addRect(QRectF(0, 0, 100, 100)); + processEvents(); QBENCHMARK { item->setTransform(transform); - item->transform(); // prevent lazy optimizing } } @@ -188,10 +204,10 @@ void tst_QGraphicsItem::rotate() { QGraphicsScene scene; QGraphicsItem *item = scene.addRect(QRectF(0, 0, 100, 100)); + processEvents(); QBENCHMARK { item->rotate(45); - item->transform(); // prevent lazy optimizing } } @@ -199,10 +215,10 @@ void tst_QGraphicsItem::scale() { QGraphicsScene scene; QGraphicsItem *item = scene.addRect(QRectF(0, 0, 100, 100)); + processEvents(); QBENCHMARK { item->scale(2, 2); - item->transform(); // prevent lazy optimizing } } @@ -210,10 +226,10 @@ void tst_QGraphicsItem::shear() { QGraphicsScene scene; QGraphicsItem *item = scene.addRect(QRectF(0, 0, 100, 100)); + processEvents(); QBENCHMARK { item->shear(1.5, 1.5); - item->transform(); // prevent lazy optimizing } } @@ -221,10 +237,10 @@ void tst_QGraphicsItem::translate() { QGraphicsScene scene; QGraphicsItem *item = scene.addRect(QRectF(0, 0, 100, 100)); + processEvents(); QBENCHMARK { item->translate(100, 100); - item->transform(); // prevent lazy optimizing } } @@ -232,10 +248,10 @@ void tst_QGraphicsItem::setRotation() { QGraphicsScene scene; QGraphicsItem *item = scene.addRect(QRectF(0, 0, 100, 100)); + processEvents(); QBENCHMARK { item->setRotation(45); - item->transform(); // prevent lazy optimizing } } -- cgit v0.12 From 2c53e6c50e7f47fa60b6cf8293651f8eaf05ebf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Wed, 17 Feb 2010 15:35:36 +0100 Subject: Remove unstable test case from QGraphicsItem::setTransform benchmark. The item's transform is identity by default, so trying to set an indentiy transform again does too little in order to measure it with stable results. --- tests/benchmarks/gui/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/benchmarks/gui/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/benchmarks/gui/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp index d452593..ec77eb0 100644 --- a/tests/benchmarks/gui/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/benchmarks/gui/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp @@ -179,7 +179,6 @@ void tst_QGraphicsItem::setTransform_data() { QTest::addColumn("transform"); - QTest::newRow("id") << QTransform(); QTest::newRow("rotate 45z") << QTransform().rotate(45); QTest::newRow("scale 2x2") << QTransform().scale(2, 2); QTest::newRow("translate 100, 100") << QTransform().translate(100, 100); -- cgit v0.12 From 9531f924478d78f0a679305cd2e5f1b4c4dd849e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Wed, 17 Feb 2010 15:50:44 +0100 Subject: Remove unusable test case from QGraphicsItem benchmark. setRotation() is already covered by the rotate() test case. --- .../gui/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/tests/benchmarks/gui/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/benchmarks/gui/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp index ec77eb0..e17cf1c 100644 --- a/tests/benchmarks/gui/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/benchmarks/gui/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp @@ -72,7 +72,6 @@ private slots: void scale(); void shear(); void translate(); - void setRotation(); }; tst_QGraphicsItem::tst_QGraphicsItem() @@ -243,16 +242,5 @@ void tst_QGraphicsItem::translate() } } -void tst_QGraphicsItem::setRotation() -{ - QGraphicsScene scene; - QGraphicsItem *item = scene.addRect(QRectF(0, 0, 100, 100)); - processEvents(); - - QBENCHMARK { - item->setRotation(45); - } -} - QTEST_MAIN(tst_QGraphicsItem) #include "tst_qgraphicsitem.moc" -- cgit v0.12