diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2010-03-15 23:05:06 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2010-03-15 23:21:39 (GMT) |
commit | ad70622193f8a34c28b6536521f8612e0b500fbf (patch) | |
tree | 9c4f113912c9c66669e50d359cb506700f8d2b9a /tests/benchmarks/gui | |
parent | 792978f693087dfecb1b9a6479e13ab75305d0d6 (diff) | |
download | Qt-ad70622193f8a34c28b6536521f8612e0b500fbf.zip Qt-ad70622193f8a34c28b6536521f8612e0b500fbf.tar.gz Qt-ad70622193f8a34c28b6536521f8612e0b500fbf.tar.bz2 |
Optimize QRegion::intersects(QRect).
Further optimize for the common case where numRects == 1. Benchmarks
included.
Reviewed-by: Samuel
Diffstat (limited to 'tests/benchmarks/gui')
-rw-r--r-- | tests/benchmarks/gui/painting/qregion/main.cpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/benchmarks/gui/painting/qregion/main.cpp b/tests/benchmarks/gui/painting/qregion/main.cpp index 3d16e41..1d19854 100644 --- a/tests/benchmarks/gui/painting/qregion/main.cpp +++ b/tests/benchmarks/gui/painting/qregion/main.cpp @@ -49,6 +49,9 @@ class tst_qregion : public QObject private slots: void map_data(); void map(); + + void intersects_data(); + void intersects(); }; @@ -84,6 +87,53 @@ void tst_qregion::map() } } +void tst_qregion::intersects_data() +{ + QTest::addColumn<QRegion>("region"); + QTest::addColumn<QRect>("rect"); + + QRegion region(0, 0, 100, 100); + QRegion complexRegion; + complexRegion = complexRegion.united(QRect(0, 0, 100, 100)); + complexRegion = complexRegion.united(QRect(120, 20, 100, 100)); + + { + QRect rect(0, 0, 100, 100); + QTest::newRow("same -- simple") << region << rect; + } + { + QRect rect(10, 10, 10, 10); + QTest::newRow("inside -- simple") << region << rect; + } + { + QRect rect(110, 110, 10, 10); + QTest::newRow("outside -- simple") << region << rect; + } + + { + QRect rect(0, 0, 100, 100); + QTest::newRow("same -- complex") << complexRegion << rect; + } + { + QRect rect(10, 10, 10, 10); + QTest::newRow("inside -- complex") << complexRegion << rect; + } + { + QRect rect(110, 110, 10, 10); + QTest::newRow("outside -- complex") << complexRegion << rect; + } +} + +void tst_qregion::intersects() +{ + QFETCH(QRegion, region); + QFETCH(QRect, rect); + + QBENCHMARK { + region.intersects(rect); + } +} + QTEST_MAIN(tst_qregion) #include "main.moc" |