summaryrefslogtreecommitdiffstats
path: root/src/testlib/qtestresult.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2022-06-02 20:37:11 +0200
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2022-06-03 09:01:46 +0000
commit474792a751a1201fc8d88d6c00e322fdf35047b1 (patch)
treefa796d327b631776f26414705a806274c396c183 /src/testlib/qtestresult.cpp
parent66bcb66a51b523fdb6dabefa6366abed17f3b06f (diff)
QCOMPARE/QVERIFY: fix huge pessimisation in QTestResult
The old code allocated a stack buffer, but asked the runtime to zero-initialize it. That's 1KiB of writes to the stack on every QCOMPARE and QVERIFY before any actual work is done. Fixing this little laissez-faire to just initialize the first character in the buffer results in nice little speedups of up to or exceeding 2x. Amends d946507727b363326d05f48da93c2af04bdda76d. [ChangeLog][QtTestLib] Optimized successful QCOMPARE and QVERIFY for an up to 2x speedup. This has the potential to meaningfully reduce the load on the CI, so picking all the way to 5.15. Pick-to: 6.3 6.2 5.15 Change-Id: Ib93d69282ec87cbd26a60e4ac14413e8cef8ff78 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/testlib/qtestresult.cpp')
-rw-r--r--src/testlib/qtestresult.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/testlib/qtestresult.cpp b/src/testlib/qtestresult.cpp
index beb6291008..40e76146ba 100644
--- a/src/testlib/qtestresult.cpp
+++ b/src/testlib/qtestresult.cpp
@@ -294,7 +294,8 @@ bool QTestResult::verify(bool statement, const char *statementStr,
{
QTEST_ASSERT(statementStr);
- char msg[1024] = {'\0'};
+ char msg[1024];
+ msg[0] = '\0';
if (QTestLog::verboseLevel() >= 2) {
qsnprintf(msg, 1024, "QVERIFY(%s)", statementStr);
@@ -353,7 +354,8 @@ static bool compareHelper(bool success, const char *failureMsg,
bool hasValues = true)
{
const size_t maxMsgLen = 1024;
- char msg[maxMsgLen] = {'\0'};
+ char msg[maxMsgLen];
+ msg[0] = '\0';
QTEST_ASSERT(expected);
QTEST_ASSERT(actual);