-
Notifications
You must be signed in to change notification settings - Fork 120
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
Performance improvement: limit number of calls to "supported_platforms(filename)" #727
Comments
Have you tried to keep the unzip directory? from fmpy import *
unzipdir = extract(filename)
simulate_fmu(filename=unzipdir) There are more tricks to reduce the CPU time for repeated simulations (see https://github.com/CATIA-Systems/FMPy/blob/main/fmpy/examples/efficient_loops.py). In the case of Another option you could try as a workaround is to simply monkey patch import fmpy
from fmpy import simulate_fmu
filename = "Dahlquist.fmu"
platforms = fmpy.supported_platforms(filename)
def cached_supported_platforms(filename):
return platforms
fmpy.supported_platforms = cached_supported_platforms
simulate_fmu(filename) |
Thanks for the feedback. We will try that. |
@t-sommer We have implemented your suggestion for the caching (we were already doing the "unzip" of the fmu). It already helped up by improving 20% on our case. |
Dear,
We are using fmpy inside a larger application where we are calling numerous times the "simulate_fmu" function with the same FMU.
More precisely, we are simulating a large period (e.g. 1 day) and each call to simulate_fmu is limited to 1 minute.
In the current implementation of FMPY, the function "supported_platforms(filename)" is called each time we call simulate_fmu.
It turns out that the total time spent in "supported_platforms" is around 26% of the total computation time (disk access is really slow)
Of course, in this particular situation, the call to the "supported_platforms" might have been done only once.
I was wondering if it was possible to skip the call to "supported_platforms" when it's not the first call for a given fmu.
Some possibilities might be:
What do you think of such modifications?
The text was updated successfully, but these errors were encountered: