Skip to content

Conversation

vittorioromeo
Copy link

This PR enables precompiled headers via the CATCH_ENABLE_PCH CMake option, aiming to significantly speed up compilation times.

Description

These are some benchmark results on my machine with the following specs:

  • Intel Core i9-13900K
  • 32GB DDR5-6400 RAM
  • EVO Plus 900 NVMe SSD
#
#
# given this CMake command...
cmake .. -DCMAKE_BUILD_TYPE=Debug -GNinja 
         -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DCMAKE_CXX_COMPILER=clang++ 
         -DCMAKE_CXX_FLAGS="-ftime-trace -Wall -Wextra -Wpedantic -Wno-ignored-attributes" 
         -DCATCH_DEVELOPMENT_BUILD=1 -DCATCH_BUILD_EXAMPLES=1 -DCATCH_BUILD_EXTRA_TESTS=1 -DCATCH_BUILD_FUZZERS=0

#
#
# ...with PCH disabled:
hyperfine "ninja clean && ninja" -n5 --warmup 1

Benchmark 1: 5
  Time (mean ± σ):     14.559 s ±  0.220 s    [User: 245.178 s, System: 33.759 s]
  Range (min … max):   14.362 s … 15.001 s    10 runs

#
#
# ...with PCH enabled:
hyperfine "ninja clean && ninja" -n5 --warmup 1

Benchmark 1: 5
  Time (mean ± σ):      9.718 s ±  0.165 s    [User: 104.442 s, System: 30.406 s]
  Range (min … max):    9.584 s … 10.152 s    10 runs

I get a ~5.0s speed-up for a full recompilation of Catch. I expect the speed-up to be more significant for machines with less cores.

Let's see if CI is happy with these changes :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant