qt5base-lts/tests/benchmarks/corelib/tools
Mitch Curtis 4f2c96eaa8 Iterate over the smaller set in QSet::intersect().
When calling intersect() on a large (1000000 items) QSet, with a small
(1000 items) QSet as the argument, the function takes signifcantly
longer than when the operand and the argument are reversed. This is
because the operand set is always iterated over in its entirety.

This patch changes intersect() to iterate over the smaller set. This
reduces the large operand scenario's benchmark to ~0.000063
milliseconds, compared to the current ~134 milliseconds:

1000000.intersect(1000) = empty: 0.000063 (was 134)
1000.intersect(1000000) = empty: 0.000039 (was 0.000036)
1000000.intersect(1000) = 500: 0.10 vs (was 130)
1000.intersect(1000000) = 500: 0.023 vs (was 0.093)
1000000.intersect(1000) = 1000: 0.20 vs (was 139)
1000.intersect(1000000) = 1000: 0.017 vs (was 0.016)

Task-number: QTBUG-22026

Change-Id: I54b25c49c78c458fef355e9c6222da8a64c7681f
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2013-06-05 09:35:42 +02:00
..
containers-associative Whitespace cleanup: remove trailing whitespace 2013-03-16 20:22:50 +01:00
containers-sequential Update copyright year in Digia's license headers 2013-01-18 09:07:35 +01:00
qalgorithms Update copyright year in Digia's license headers 2013-01-18 09:07:35 +01:00
qbytearray Update copyright year in Digia's license headers 2013-01-18 09:07:35 +01:00
qchar Update copyright year in Digia's license headers 2013-01-18 09:07:35 +01:00
qcontiguouscache Update copyright year in Digia's license headers 2013-01-18 09:07:35 +01:00
qhash Update copyright year in Digia's license headers 2013-01-18 09:07:35 +01:00
qlist Update copyright year in Digia's license headers 2013-01-18 09:07:35 +01:00
qlocale Remove QLocalePrivate::m_localeID 2013-04-23 18:57:45 +02:00
qmap QMap - add insert overload that provide a hint 2013-03-06 18:56:17 +01:00
qrect Update copyright year in Digia's license headers 2013-01-18 09:07:35 +01:00
qregexp Whitespace cleanup: remove trailing whitespace 2013-03-16 20:22:50 +01:00
qset Iterate over the smaller set in QSet::intersect(). 2013-06-05 09:35:42 +02:00
qstring Update copyright year in Digia's license headers 2013-01-18 09:07:35 +01:00
qstringbuilder Update copyright year in Digia's license headers 2013-01-18 09:07:35 +01:00
qstringlist Update copyright year in Digia's license headers 2013-01-18 09:07:35 +01:00
qvector Whitespace cleanup: remove trailing whitespace 2013-03-16 20:22:50 +01:00
tools.pro Remove QLocalePrivate::m_localeID 2013-04-23 18:57:45 +02:00