Optimize TestSuite comparison macro compile times.#140
Draft
Conversation
Majority of the work done in this class is template-independent, so this avoid a lot of needless template instantiations.
Since this is a failure case, it doesn't really matter if it takes 10x more time at runtime. But it definitely adds more work for the compiler, and that's where most of human time is usually spent -- iterating on the test code. So don't.
Same as was done for the generic Comparator, but here it's quite a lot heavier so the impact should be bigger.
804de7e to
468afdb
Compare
Codecov Report
@@ Coverage Diff @@
## master #140 +/- ##
=======================================
Coverage 98.40% 98.40%
=======================================
Files 124 125 +1
Lines 9504 9541 +37
=======================================
+ Hits 9352 9389 +37
Misses 152 152
Continue to review full report at Codecov.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.cppin 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
ComparatorandCompare::Containeris 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?