Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/src/Progmasoft/Catch3/Internal/RunContext.cpp
diff options
context:
space:
mode:
authorMartin Hořeňovský2026-09-03 20:16:55 +0200
committerMartin Hořeňovský2026-09-03 20:22:37 +0200
commitde1330d036168492a04b649a1fa0593faece6f74 (patch)
tree09fae90a513ef3ae05c2027279715276c8b3f910 /src/Progmasoft/Catch3/Internal/RunContext.cpp
parent317ac1ed4c0bb6e6b91eafc817e05c488feffcb3 (diff)
downloadcatch3-de1330d036168492a04b649a1fa0593faece6f74.tar.gz
Avoid bad compile time scaling of test registration with optimizations
GCC is especially bad, as it had quadratic scaling in the number of registered test cases in a TU, but Clang also scaled superlinearly, and this commit fixes both. AIUI: 1) Each `TEST_CASE` creates a separate global fragment to handle creating the `unique_ptr<ITestInvoker>`, moving the instance into AutoReg, destroying the old instance, etc, etc. 2) With optimizations enabled, the compiler merges all these global fragments into one big global fragment. 3) Then the compiler runs various optimizations passes on this new global fragment. 4) Because some of the passes scale superlinearly, the compilation times scale superlinearly in the number of `TEST_CASE` in a translation unit. For bonus point, no optimization actually happens. This commit fixes the problem (for non-LTO builds) by adding new `AutoReg` constructor, one that takes the function pointer raw, instead of wrapped in `ITestInvoker`. By delaying the construction of the `ITestInvoker` into the outlined constructor, we no longer create big global fragments for the compiler to optimize.
Diffstat (limited to 'src/Progmasoft/Catch3/Internal/RunContext.cpp')
0 files changed, 0 insertions, 0 deletions