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

Refactor test.cpp #7487

Merged
merged 18 commits into from Aug 28, 2022
Merged

Refactor test.cpp #7487

merged 18 commits into from Aug 28, 2022

Conversation

dbaileychess
Copy link
Collaborator

Splits tests/test.cpp into various modules to reduce compilation time.

This of course, doesn't decrease the amount of work, but it allows parallelized builds to go much faster. Especially on incremental rebuilds.

At least on my machine, it reduced the compilation time from 13s down to 5s, for this test.cpp in isolation. It is actually a tad bit lower than a file I created in this PR: monster_test.cpp is 5.6s.

I think the rest of this can be refactored more, but since it is no longer the biggest offending thing, I am going to devote my time to that: the idl_parser.cpp

@dbaileychess
Copy link
Collaborator Author

This is the time for the following

make clean
time make -j

On my computer, which is pretty beefy.

With this refactor:

Executed in   21.09 secs    fish           external
   usr time  183.36 secs  637.00 micros  183.36 secs
   sys time    6.27 secs  181.00 micros    6.27 secs

Without this refactor (at head):

________________________________________________________
Executed in   24.55 secs    fish           external
   usr time  168.07 secs  591.00 micros  168.07 secs
   sys time    5.50 secs  165.00 micros    5.50 secs

So ~3.5 seconds savings overall (~15% speedup) just for a refactor.

@aardappel
Copy link
Collaborator

It's probably a good idea to split these up.. if anything, I question the organization, either they should all be named test_*.cpp instead of *_test.cpp so they're easier to work with in the current structure, or moved to test/cpp etc.

Also, not sure I see the utility of having a headerfile for each, since there's nothing in them.. I'd make 1 test function per .cpp and just extern that in test.cpp to simplify things.

@dbaileychess
Copy link
Collaborator Author

The Google style is to postfix _test to the thing being tested.

In terms of tests/cpp I was going to move everything Non-C++ out of tests/ and just leave the c++ tests located here. I think I prefer the $lang/test/ breakdown anyways.

Extern is frowned upon (https://google.github.io/styleguide/cppguide.html#Forward_Declarations) for this kind of thing. Yes, adding the header files seems overkill, but I think it is the correct thing to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants