Howdy,
I've recently switched from Boost.Test to CATCH on all my C++ projects, and I am loving it but for a particular pain point which is becoming increasingly difficult to ignore. Namely, performance. Compiling a test suite takes much longer than previously. Each individual file in the test suite now typically takes on the order of 5+ seconds to compile.
To reduce this down to the simplest possible quantifiable test case, here follow some figures for standalone compilation of the first factorial
example from the tutorial:
time g++ factorial.cc # 6.2s
time g++ -std=c++11 factorial.cc # 7.8s
time clang++ factorial.cc # 4.0s
time clang++ -std=c++11 -stdlib=libc++ factorial.cc # 4.7s
Now, if we do go still more minimalistic, reducing the input file to simply the following fundamental skeletal minimum:
#define CATCH_CONFIG_MAIN
#include "catch.hpp"
TEST_CASE("skeleton") {}
…the build times do improve, but not markedly so:
time g++ skeleton.cc # 5.6s
time g++ -std=c++11 skeleton.cc # 6.6s
time clang++ skeleton.cc # 3.3s
time clang++ -std=c++11 -stdlib=libc++ skeleton.cc # 4.1s
This latter problem is particularly pressing for me, as it means that a test suite which is still mostly in development takes ages to build even though it doesn't yet do much anything, affecting the test-driven development lifecycle. The only way to speed up iterations is to edit the Makefile to remove mentions of stub files, or else to actually comment out the CATCH inclusion from each one. A workaround, at best.
All aforementioned figures were obtained with CATCH 1.0 build 32, timed with GCC 4.8.2 and Clang 3.4 running on Mac OS X 10.7.5 on a MacBook with a 1.8 GHz Intel Core i7 processor and 4 GB of RAM. Each individual timing was averaged from five repeated runs.
Are there perchance any preprocessor macros or the like that one might define in order to reduce the number of lines of magic that the compiler needs to process for each compilation? I don't (at present, anyhow) need any of the more advanced functionality provided by CATCH; just making basic REQUIRE() assertions would pretty much suffice.
Thanks for your consideration,
Arto
--