-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to improve compilation speed? #836
Comments
Hi @evandrocoan, Thanks for the detailed report. However I do wonder if you have the latest version of Catch (1.8.0)? There are definitely The compile time improvements should be noticeable - but not earth shattering. This is just an incremental step - and a place for us to put slightly more disruptive changes in (hence the need to opt-in with the As for why having the separate main file actually takes longer than without: that's because you're building the whole project - which now has the same amount of user code, but more translation units. The advice given in "slow-compiles" is really to improve incremental compile times - which is where you usually most feel the pain if compilation is slow. When you are in a test-compile-check cycle you don't usually need to rebuild the main source file, so having that contain the more heavyweight portion of Catch is a win. |
Yeah, now I updated and I found them also. I was not using the include file The compile time still do not improving. Sometimes I got catch_main.cpp #define CATCH_CONFIG_MAIN
#define CATCH_CONFIG_FAST_COMPILE
#include "libraries/Catch/single_include/catch.hpp" catch_tests.cpp #define CATCH_CONFIG_FAST_COMPILE
#include "libraries/Catch/single_include/catch.hpp"
unsigned int Factorial( unsigned int number )
{
return number <= 1 ? number : Factorial(number-1)*number;
}
TEST_CASE( "Factorials are computed", "[factorial]" )
{
REQUIRE( Factorial(1) == 1 );
REQUIRE( Factorial(2) == 2 );
REQUIRE( Factorial(3) == 6 );
REQUIRE( Factorial(10) == 3628800 );
} Basically 99% of the time the ld.exe is running: |
So, I got around looking at this and I have to ask: Was your g++ binary compiled in debug mode? Or maybe the linker, because the attached gif shows ld taking long time. Even my pretty ancient Zacate (1600 MHz, tiny caches, generally quite slow), can compile Catch main in 15s. My actual notebook takes ~8s to compile the main, ~9s to compile the factorial example + main. As to the new compile time option, |
Also, you could try out Zapcc, which is free for (quot from their page) non-commercial entities, and for start-up companies in pre revenues/funding stages. |
@horenmar my gcc is Though, your compilation times @kirbyfan64 thanks for pointing |
@evandrocoan In general, Catch's main takes a looong time to compile and the tests aren't exactly fast either, so if you are stuck with 1GHz cores, then you will see some crazy compile times. If doctest covers your need, use it, it was made as reimplementation of Catch's core with minimal compile time overhead, but is missing quite a few features. We aren't out for world domination and will not hunt you down for not using Catch 😄 |
How to improve compilation speed?
First, there is not any mention of the
CATCH_CONFIG_FAST_COMPILE
on the single include filesingle_include\catch.hpp
. How it is supposed to improve the compilation time?On my computer, takes about
3.2 seconds
to build and run a simple application on my computer usingg++ 5.4-cygwin
. Seems acceptable time, as my CPU is under-clocked 67%.However, following the steps on https://github.com/philsquared/Catch/blob/master/docs/slow-compiles.md, takes about
21.3 seconds
to build & run this simple unit test, instead of40
seconds when I was building the main altogether:catch_tests.cpp
Now I am including
CATCH_CONFIG_FAST_COMPILE
on both files, in hope to improve this speed:catch_main.cpp
catch_tests.cpp
But it does not seem to improve the compilation speed. Are there anything it could be done beyond not use
Catch
as Unit Test framework, to improve the compilation speed from21.3 seconds
?I am using this makefile to build:
Makefile
The text was updated successfully, but these errors were encountered: