# Optimizing CTest runners

**URL:** https://discourse.cmake.org/t/optimizing-ctest-runners/9415
**Category:** Usage
**Tags:** tool:ctest
**Created:** [November 13, 2023, 11:08am UTC](https://discourse.cmake.org/t/optimizing-ctest-runners/9415 "2023-11-13T11:08:25Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Lecris](https://discourse.cmake.org/user_avatar/discourse.cmake.org/lecris/32/3193_2.png) [@Lecris](https://discourse.cmake.org/u/Lecris)
#### Post date: [November 13, 2023, 11:08am UTC](https://discourse.cmake.org/t/optimizing-ctest-runners/9415/1 "2023-11-13T11:08:25Z")

</div>

I have noticed that `ctest` is able to optimize the order of tests that are run in parallel based on the previous execution. My question around this, is what files are needed to be cached to take advantage of this outside of a `CDash` environment? Are there other such optimizations that one should be aware of?

---

<div class="post-metadata">

### Author: ![scivision](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/a87d85/32.png) [@scivision](https://discourse.cmake.org/u/scivision)
#### Post date: [November 13, 2023, 1:44pm UTC](https://discourse.cmake.org/t/optimizing-ctest-runners/9415/2 "2023-11-13T13:44:24Z")

</div>

Copied from [CMake CTest cost data | Scientific Computing](https://www.scivision.dev/cmake-ctest-cost/)

> CMake’s CTest assigns a dynamic [COST](https://cmake.org/cmake/help/latest/prop_test/COST.html) to each test that updates each time the test is run. Kitware considers the cost test data to be [undocumented](https://gitlab.kitware.com/cmake/cmake/-/merge_requests/4853#note_772696) behavior, so it’s not part of the CMake COST docs.

> The computed test cost data is stored under `${CMAKE_BINARY_DIR}/Testing/Temporary/CTestCostData.txt` This file stores data for each test in a row:

```auto
  TestName NumberOfTestRuns Cost

```

---

<div class="post-metadata">

### Author: ![Lecris](https://discourse.cmake.org/user_avatar/discourse.cmake.org/lecris/32/3193_2.png) [@Lecris](https://discourse.cmake.org/u/Lecris)
#### Post date: [November 13, 2023, 2:19pm UTC](https://discourse.cmake.org/t/optimizing-ctest-runners/9415/3 "2023-11-13T14:19:14Z")

</div>

Thanks. Probably not as reliable as with `CDash`, but still it should be better than without it.

---

<div class="post-metadata">

### Author: ![scivision](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/a87d85/32.png) [@scivision](https://discourse.cmake.org/u/scivision)
#### Post date: [November 13, 2023, 3:41pm UTC](https://discourse.cmake.org/t/optimizing-ctest-runners/9415/4 "2023-11-13T15:41:05Z")

</div>

It seems like a prime candidate for updating CMake internals to use JSON as in other such files
