diff --git a/src/plugins/autotest/testcodeparser.cpp b/src/plugins/autotest/testcodeparser.cpp index e78be579651..ec4a3080cc3 100644 --- a/src/plugins/autotest/testcodeparser.cpp +++ b/src/plugins/autotest/testcodeparser.cpp @@ -5,6 +5,7 @@ #include "autotestconstants.h" #include "autotesttr.h" +#include "testsettings.h" #include "testtreemodel.h" #include @@ -360,7 +361,11 @@ void TestCodeParser::scanForTests(const QSet &filePaths, using namespace Tasking; - QList tasks{parallelLimit(std::max(QThread::idealThreadCount() / 4, 1))}; + int limit = TestSettings::instance()->scanThreadLimit(); + if (limit == 0) + limit = std::max(QThread::idealThreadCount() / 4, 1); + qCDebug(LOG) << "Using" << limit << "threads for scan."; + QList tasks{parallelLimit(limit)}; for (const FilePath &file : filteredFiles) { const auto setup = [this, codeParsers, file](Async &async) { async.setConcurrentCallData(parseFileForTests, codeParsers, file); diff --git a/src/plugins/autotest/testsettings.cpp b/src/plugins/autotest/testsettings.cpp index b4507a9d9ab..3c911202f1e 100644 --- a/src/plugins/autotest/testsettings.cpp +++ b/src/plugins/autotest/testsettings.cpp @@ -28,6 +28,12 @@ TestSettings::TestSettings() setSettingsGroup(Constants::SETTINGSGROUP); + scanThreadLimit.setSettingsKey("ScanThreadLimit"); + scanThreadLimit.setDefaultValue(0); + scanThreadLimit.setRange(0, QThread::idealThreadCount()); + scanThreadLimit.setSpecialValueText("Automatic"); + scanThreadLimit.setToolTip(Tr::tr("Number of worker threads used when scanning for tests.")); + timeout.setSettingsKey("Timeout"); timeout.setDefaultValue(defaultTimeout); timeout.setRange(5000, 36'000'000); // 36 Mio ms = 36'000 s = 10 h diff --git a/src/plugins/autotest/testsettings.h b/src/plugins/autotest/testsettings.h index 1e33269bd4f..fbcc4602914 100644 --- a/src/plugins/autotest/testsettings.h +++ b/src/plugins/autotest/testsettings.h @@ -32,6 +32,7 @@ public: void toSettings(QSettings *s) const; void fromSettings(QSettings *s); + Utils::IntegerAspect scanThreadLimit{this}; Utils::IntegerAspect timeout{this}; Utils::BoolAspect omitInternalMsg{this}; Utils::BoolAspect omitRunConfigWarn{this}; diff --git a/src/plugins/autotest/testsettingspage.cpp b/src/plugins/autotest/testsettingspage.cpp index 6c9850bc2ac..407b386052a 100644 --- a/src/plugins/autotest/testsettingspage.cpp +++ b/src/plugins/autotest/testsettingspage.cpp @@ -51,6 +51,8 @@ TestSettingsWidget::TestSettingsWidget() { auto timeoutLabel = new QLabel(Tr::tr("Timeout:")); timeoutLabel->setToolTip(Tr::tr("Timeout used when executing each test case.")); + auto scanThreadLabel = new QLabel(Tr::tr("Scan threads:")); + scanThreadLabel->setToolTip("Number of worker threads used when scanning for tests."); m_frameworkTreeWidget = new QTreeWidget; m_frameworkTreeWidget->setRootIsDecorated(false); @@ -83,6 +85,7 @@ TestSettingsWidget::TestSettingsWidget() Group generalGroup { title(Tr::tr("General")), Column { + Row { scanThreadLabel, s.scanThreadLimit, st }, s.omitInternalMsg, s.omitRunConfigWarn, s.limitResultOutput,