power-grid-model
power-grid-model copied to clipboard
[FEATURE] Static library wrapper around main model + math solver for speeding up tests
Relates to https://github.com/PowerGridModel/power-grid-model/issues/486
A major factor in the compilation is the fact that all 3 test files of the main model + the validator + the benchmark need to recompile all templates individually. Making a static library wrapper would reduce this to only 1 compilation.
The way to do that is the following:
- [ ] Add a separate library to the tests directory:
tests/cpp_test_wrappers/
- [ ] Add a
CMakeLists.txt
to expose aSTATIC
librarycpp_test_wrappers
- [ ] Add a header
tests/cpp_test_wrappers/include/cpp_test_wrappers/main_model_wrapper.hpp
- [ ] declare class:
class MainModelWrapper { private: class Impl; public: // all public methods of MainModel private: std::unique_ptr<Impl> impl_; }
- [ ] declare class:
- [ ] Add a cpp file
tests/cpp_wrappers/src/main_model_wrapper.cpp
- [ ] declare class impl:
class MainModelWrapper::Impl : public MainModel { public: using MainModel::MainModelImpl; };
- [ ] implement all public methods of MainModelWrapper by forwarding the call to
MainModel
- [ ] Add all static checks from
test_main_model_static.cpp
to this file
- [ ] declare class impl:
- [ ] Add a
- [ ] Modify
test_main_model_*.cpp
, thecpp_validation
tests and the benchmark to use this library instead of the staticMainModel
- [ ] Optionally: Create a separate test executable for
test_main_model_*
to speed up compilation for people who are developing things upstream and don't care about main model yet - [ ] Optionally: do the same for the MathModel
- [ ] Split the MathModel tests into separate files
I wonder if we are creating static library anyway, why don't we just make power_grid_model
core library itself a static library. We try to compile the header files in several compilation unit.
I've been thinking about that as well. Let's discuss offline
As discussed: we will solve this in a different way