From 5a948dd50bdd76d7a04380d6bf239cf2dae684be Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Wed, 14 Oct 2020 15:19:29 +0200 Subject: Fix [[nodiscard]] compile errors in QLocale benchmark MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Andrei Golubev --- tests/benchmarks/corelib/text/qlocale/main.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'tests/benchmarks') 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) -- cgit v1.2.3