You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some performance improvements seem to be desirable to build a global PyPSA-Earth model (see #445 and #543 for details). Profiling may be very helpful to address performance optimisation effectively.
Among Python profilers cProfiler is currently the most handy one. It belongs to the standard Python toolkit is written in C and hence is more efficient as compared with pure Pythonic profiler.
A convenient way to profile scripts being a part of Snakemake workflow is to apply a decorator function, e.g. adding to the workflow something like this:
importcProfiledefprofile(func):
"""Decorator for run function profile"""defwrapper(*args, **kwargs):
profile_filename=func.__name__+'.prof'profiler=cProfile.Profile()
result=profiler.runcall(func, *args, **kwargs)
profiler.dump_stats(profile_filename)
returnresultreturnwrapper
...
@profiledefclean_data(
input_files, ...
That will save the profiling results as a .prof file which can be analysed further with performance analysis tools. The following visualisation tools have been tested:
Currently my impession is that snakeviz is the most convenient from UX point of view. However, tuna and flameprof may address some specific performance tracing issues more precisely. The workflow graphs of may be helpful to understand the workflow sub-stages better.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Some performance improvements seem to be desirable to build a global PyPSA-Earth model (see #445 and #543 for details). Profiling may be very helpful to address performance optimisation effectively.
Among Python profilers
cProfileris currently the most handy one. It belongs to the standard Python toolkit is written in C and hence is more efficient as compared with pure Pythonicprofiler.A convenient way to profile scripts being a part of Snakemake workflow is to apply a decorator function, e.g. adding to the workflow something like this:
That will save the profiling results as a
.proffile which can be analysed further with performance analysis tools. The following visualisation tools have been tested:Snakeviz(pip install snakeviz)tuna(pip install tuna)flameprof(pip install flameprof)flameprof --cpu clean_data.prof > requests.svggrpof2dot(pip install gprof2dot)Currently my impession is that
snakevizis the most convenient from UX point of view. However,tunaandflameprofmay address some specific performance tracing issues more precisely. The workflow graphs of may be helpful to understand the workflow sub-stages better.Beta Was this translation helpful? Give feedback.
All reactions