Skip to content
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

Split unit tests into their own compilation units #257

Closed
wants to merge 26 commits into from
Closed

Conversation

jbakosi
Copy link
Member

@jbakosi jbakosi commented Jul 24, 2018

This enables more concurrency during compilation and allows rebuilding only the file changed. This leads to more compilation units, but a lot faster compilation of the unittest executable, and thus faster turn-around when writing unit tests.

Lots of boring changes, except the one in e84d8ed, which was non-trivial to fix. See also mrzechonek/tut-framework#16.


This change is Reviewable

jbakosi added 15 commits July 20, 2018 15:05
Instead of including multiple groups of unit tests via include files
into the main unit test harness translation unit, this commits breaks up
every group of unit tests into its own translation unit, thus increasing
the potential for parallel compilation.

Benchmark usign 36 cores indicates an increase in build performance of
2X in debug with clang, 3X in release with gnu, measuring the build of
the unittest harness executable only:

old:

clang/debug:develop$ time ninja unittest
[72/72] Linking CXX executable Main/unittest
real    0m59.600s
user    4m12.360s
sys     0m11.720s

gnu/release:develop$ time ninja unittest
[72/72] Linking CXX executable Main/unittest
real    1m30.254s
user    4m19.080s
sys     0m15.624s

new:

clang/debug:unittest$ time ninja unittest
[115/115] Linking CXX executable Main/unittest
real    0m28.627s
user    10m16.528s
sys     0m26.748s

gnu/release:unittest$ time ninja unittest
[115/115] Linking CXX executable Main/unittest
real    0m27.180s
user    9m39.188s
sys     0m39.148s
This way when the unit tests register themselves with the global
singleton runner, defined in UnitTest.C, using an external reference to
the runner in the tut include, at link time, all objects that reference
the runner will be visible to the linker in a single step, when linking
the unittest executable.

Previously the tests, now appearing in multiple compilation units were
bundled up into a library which in turn was linked in when creating the
executable. While this two-step rpocess worked fine with dynamic
linking, static linking, using an intermediate static library, the
linker failed to find the same global runner between the executable link
and the library.
@jbakosi jbakosi closed this Jul 29, 2018
@jbakosi jbakosi deleted the unittest branch July 29, 2018 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant