open-simulation-platform / libcosim

OSP C++ co-simulation library
https://open-simulation-platform.github.io/libcosim
Mozilla Public License 2.0
61 stars 10 forks source link

Some performance tweak #687

Closed davidhjp01 closed 2 years ago

davidhjp01 commented 2 years ago

Following updates are for further performance improvement: 1.Additional placement of LIBCOSIM_NO_FMI_LOGGING for disabling logging in step_finished_placeholder

  1. Removed step_finished_placeholder and assigned nullptr to the callback pointer.
  2. Now cosim::slave::get_variables does not create cosim::slave::variable_values for each time it's invocation, instead copies data to the argument that is passed to the function.
    • This changes the use of get_variables, see the updated test cases.
  3. In set_variable_cache::modfiy_and_get, std::unordered_map<value_reference, size_t> back_refs_ is used to only update variable values that are subject to modification (via modifier). This avoids unnecessary iteration of all variables in each simulation step.