Optimize TestSuite comparison macro compile times. #140
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I regularly get angry at how long large tests take to compile. Well, I guess relatively, building a heavy 6000-line
GltfImporterTest.cpp
in under 5 seconds is an unachievable feat in Some Other Codebases. But still.Profiling using Clang
-ftime-trace
, the biggest offenders are:<sstream>
include, about 160 ms / 3.5% -- depends on making Debug stream-free, which depends on ... making my own float printers<cmath>
, about 40 ms / 1% -- can't really do much about this, and the more I optimize, the more this will stand outTestSuite::Compare::Container<T>::printMessage()
, about 500 ms / 10% -- put it into a non-templated base. These are not so many but quite large.TestSuite::Comparator<T>::printMessage()
-- put it into a non-templated base. These are tiny but quite many, so the template base might not help as much.Comparison with SpeedScope after adding a non-templated base for both
Comparator
andCompare::Container
is above -- 4.9 seconds before, 4.5 after, time spent inprintMessage()
visibly shrinks. Trace files for reference:10% reduction in compile time is still not as significant as I hoped, further investigation needed:
operator<<()
seems to be quite heavy, anything to optimize there?