diff options
| author | Martin Hořeňovský | 2026-07-26 13:15:10 +0200 |
|---|---|---|
| committer | Martin Hořeňovský | 2026-07-26 19:51:58 +0200 |
| commit | 1079da4c5f5fea2a31d795bba95eacaa2f622849 (patch) | |
| tree | 4f708b68ab9038d75a50e15467b3ea8182e939f1 /examples | |
| parent | 60c8b878292ec4afc625a807cdc3902397a408a3 (diff) | |
| download | catch3-1079da4c5f5fea2a31d795bba95eacaa2f622849.tar.gz | |
Avoid quadratic JSON array parse behaviour in `catch_discover_tests`
Using CMake's `string(JSON` to parse JSON array leads to quadratic
running time in number of tests, see https://gitlab.kitware.com/cmake/cmake/-/work_items/27985
This leads to _terrible_ runtime for `catch_discover_tests` when called
on binaries with lot of tests (1k+). To get reasonable runtimes, we have
to avoid using `string(JSON` to parse out the individual test objects
from the array with all tests.
This commit replaces the sane approach of using real JSON parser with
a set of terrible hacks, where we use CMake's string APIs to split the
JSON array on what looks like object boundary (`}<ws>*,<ws>*{`), and then
checking whether the resulting thing can be parsed as JSON object. If not,
we append the next piece and check again. And again, and again, until we
get a proper JSON object.
This is all around a hilariously terrible idea, however:
1) It works in practice for all tested inputs.
2) It improves the time it takes to run `catch_discover_tests` on binary
with 1k tests from 4.2s to 1.1s and 2k tests from 16s to 3.9s.
Diffstat (limited to 'examples')
0 files changed, 0 insertions, 0 deletions