Reduce run time of tst_QRegularExpression::threadSafety

This test was taking so much time that it regularly timed out on WinRT
and when running in qemu. Reduce it from around 40 to 7 seconds on a
powerful desktop.
Now it either runs for two full seconds for each test function or until
it has done 50 iterations.

Fixes: QTBUG-71405
Change-Id: If752c1e65d3b19009b883f64edc96d020df479d1
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
bb10
Frederik Gladhorn 2018-10-25 15:08:13 +02:00 committed by Liang Qi
parent ca3ac2e1c7
commit e00c73911a
1 changed files with 3 additions and 2 deletions

View File

@ -2135,11 +2135,12 @@ void tst_QRegularExpression::threadSafety()
QFETCH(QString, pattern);
QFETCH(QString, subject);
QElapsedTimer time;
time.start();
static const int THREAD_SAFETY_ITERATIONS = 50;
const int threadCount = qMax(QThread::idealThreadCount(), 4);
for (int threadSafetyIteration = 0; threadSafetyIteration < THREAD_SAFETY_ITERATIONS; ++threadSafetyIteration) {
for (int threadSafetyIteration = 0; threadSafetyIteration < THREAD_SAFETY_ITERATIONS && time.elapsed() < 2000; ++threadSafetyIteration) {
QRegularExpression re(pattern);
QVector<MatcherThread *> threads;