Start slow tests early when using ctest -j jobs

When running ctest -j 16, the wall time executing the tests varies a lot because some tests are much slower than others. If the slow tests are started first the suite completes quick. I couldn’t find anything to hint ctest running some tests early except for restricting the order in which the tests must run. I’d rather avoid that. I guess my ideal would be if the system learned to schedule the tests efficiently from wall and cpu time stats collected by previous runs. That would also allow to report time differences compared to previous runs.

Is it possible to realize this using the current ctest?

ctest already makes use of timing data from previous runs in the same build directory. It stores information in an undocumented location (<build-dir>/Testing/Temporary/CTestCostData.txt) and uses that to try to start longer running (higher cost) tests first on subsequent runs.

You can also explicitly specify the cost of a test with the COST test property.