summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2021-07-20 14:45:10 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-07-23 18:35:22 +0000
commit9d07711bfd41875a7aadcf7a61e38768b962d0c3 (patch)
tree60fb462197127bd2b6eb214eedffc4d016aaab0b
parenta690703d3919a5888710b7e545416751e43b1046 (diff)
Make QSqlRecord benchmarks non-fatuous
Because QBENCHMARK re-runs its block repeatedly, to get sensible data, the block needs to actually do something when repeated. Since these tests had blocks that looped while (qry.next()), they left qry at its end state, so such repeats tested nothing. Use seek(0) at the start of each cycle to actually do the work repeatedly when the block is repeated. As a drive-by, split a long line. Task-number: QTBUG-91713 Change-Id: Id46f77dc5e71335871af79ff61e1980b5f636179 Reviewed-by: Andy Shaw <andy.shaw@qt.io> (cherry picked from commit 432eab3bc09bd4c6e6904905fae53f64227a1518) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--tests/benchmarks/sql/kernel/qsqlrecord/tst_qsqlrecord.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/tests/benchmarks/sql/kernel/qsqlrecord/tst_qsqlrecord.cpp b/tests/benchmarks/sql/kernel/qsqlrecord/tst_qsqlrecord.cpp
index 6e88bad1cd..c2533f817f 100644
--- a/tests/benchmarks/sql/kernel/qsqlrecord/tst_qsqlrecord.cpp
+++ b/tests/benchmarks/sql/kernel/qsqlrecord/tst_qsqlrecord.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
- ** Copyright (C) 2018 The Qt Company Ltd.
+ ** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
@@ -178,7 +178,8 @@ void tst_QSqlRecord::benchmarkRecord()
const auto tableName = qTableName("record", __FILE__, db);
{
QSqlQuery qry(db);
- QVERIFY_SQL(qry, exec("create table " + tableName + " (id int NOT NULL, t_varchar varchar(20), "
+ QVERIFY_SQL(qry, exec("create table " + tableName +
+ " (id int NOT NULL, t_varchar varchar(20), "
"t_char char(20), primary key(id))"));
// Limit to 500: at 600, the set-up takes nearly 5 minutes
for (int i = 0; i < 500; i++)
@@ -188,6 +189,7 @@ void tst_QSqlRecord::benchmarkRecord()
QBENCHMARK {
while (qry.next())
qry.record();
+ QVERIFY(qry.seek(0));
}
}
tst_Databases::safeDropTables(db, QStringList() << tableName);
@@ -203,6 +205,7 @@ void tst_QSqlRecord::benchFieldName()
QBENCHMARK {
while (qry.next())
qry.value("r");
+ QVERIFY(qry.seek(0));
}
}
}
@@ -218,6 +221,7 @@ void tst_QSqlRecord::benchFieldIndex()
QBENCHMARK {
while (qry.next())
qry.value(0);
+ QVERIFY(qry.seek(0));
}
}
}