Make loop variables references in date benchmark

This more accurately simulates real-world usage.

Change-Id: Ib1b49d165b3cfaef2bef51e958a1830cc7f8c285
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
David Skoland 2021-04-26 12:22:05 +02:00
parent 5acb1af6b6
commit fea8ed0dcb

View File

@ -149,7 +149,7 @@ void tst_QDate::daysInYear()
{ {
const auto list = yearly(1601, 2401); const auto list = yearly(1601, 2401);
QBENCHMARK { QBENCHMARK {
for (const QDate date : list) for (const QDate &date : list)
date.daysInYear(); date.daysInYear();
} }
} }
@ -167,7 +167,7 @@ void tst_QDate::getSetDate()
QDate store; QDate store;
const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020); const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
QBENCHMARK { QBENCHMARK {
for (const auto test : list) { for (const auto &test : list) {
int year, month, day; int year, month, day;
test.getDate(&year, &month, &day); test.getDate(&year, &month, &day);
store.setDate(year, month, day); store.setDate(year, month, day);
@ -181,7 +181,7 @@ void tst_QDate::addDays()
QDate store; QDate store;
const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020); const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
QBENCHMARK { QBENCHMARK {
for (const auto test : list) for (const auto &test : list)
store = test.addDays(17); store = test.addDays(17);
} }
Q_UNUSED(store); Q_UNUSED(store);
@ -192,7 +192,7 @@ void tst_QDate::addMonths()
QDate store; QDate store;
const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020); const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
QBENCHMARK { QBENCHMARK {
for (const auto test : list) for (const auto &test : list)
store = test.addMonths(17); store = test.addMonths(17);
} }
Q_UNUSED(store); Q_UNUSED(store);
@ -203,7 +203,7 @@ void tst_QDate::addYears()
QDate store; QDate store;
const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020); const auto list = daily(JULIAN_DAY_2010, JULIAN_DAY_2020);
QBENCHMARK { QBENCHMARK {
for (const auto test : list) for (const auto &test : list)
store = test.addYears(17); store = test.addYears(17);
} }
Q_UNUSED(store); Q_UNUSED(store);