summaryrefslogtreecommitdiffstats
path: root/tests/benchmarks
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2020-10-14 15:19:29 +0200
committerEdward Welbourne <edward.welbourne@qt.io>2020-10-19 17:45:30 +0200
commit5a948dd50bdd76d7a04380d6bf239cf2dae684be (patch)
treebabf7b0342667eeb07f39c40f8425df6746e2f71 /tests/benchmarks
parent55e16b25f52fdd1b945d3f94d79ce85d88cb69ec (diff)
Fix [[nodiscard]] compile errors in QLocale benchmark
QString::toUpper() now insists we use its return, so the benchmark won't compile unless we do so. Also document the helper macro used by the tests, to explain why it's even there at all. Change-Id: I830f121d92867bcd09277ecdeb1c764413b34fa6 Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Diffstat (limited to 'tests/benchmarks')
-rw-r--r--tests/benchmarks/corelib/text/qlocale/main.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/tests/benchmarks/corelib/text/qlocale/main.cpp b/tests/benchmarks/corelib/text/qlocale/main.cpp
index 38d94af143..7047338800 100644
--- a/tests/benchmarks/corelib/text/qlocale/main.cpp
+++ b/tests/benchmarks/corelib/text/qlocale/main.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -44,25 +44,26 @@ static QString data()
return QStringLiteral("/qt-5/qtbase/tests/benchmarks/corelib/tools/qlocale");
}
+// Make individual cycles O(a few) msecs, rather than tiny fractions thereof:
#define LOOP(s) for (int i = 0; i < 5000; ++i) { s; }
void tst_QLocale::toUpper_QLocale_1()
{
QString s = data();
- QBENCHMARK { LOOP(QLocale().toUpper(s)) }
+ QBENCHMARK { LOOP(QString t(QLocale().toUpper(s))) }
}
void tst_QLocale::toUpper_QLocale_2()
{
QString s = data();
QLocale l;
- QBENCHMARK { LOOP(l.toUpper(s)) }
+ QBENCHMARK { LOOP(QString t(l.toUpper(s))) }
}
void tst_QLocale::toUpper_QString()
{
QString s = data();
- QBENCHMARK { LOOP(s.toUpper()) }
+ QBENCHMARK { LOOP(QString t(s.toUpper())) }
}
QTEST_MAIN(tst_QLocale)