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
I've used cProfile in the past, but I found line_profiler to be much more user friendly. It handles pretty much everything for you and only requires adding a @profile decorator to the function to target.
The package is called line_profiler but the executable is kernprof, and it is run with this command:
kernprof -v -l script_to_profile.py
Memory
Memory profiling has proved to be much more difficult. I've used memory_profiler due to its similar API to line_profiler - you simply add the same @profile decorator to a function. However, the same code differs in memory measurement from run to run, so getting accurate results seems elusive.
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
-
Speed / Time
I've used cProfile in the past, but I found line_profiler to be much more user friendly. It handles pretty much everything for you and only requires adding a
@profile
decorator to the function to target.The package is called
line_profiler
but the executable iskernprof
, and it is run with this command:Memory
Memory profiling has proved to be much more difficult. I've used memory_profiler due to its similar API to
line_profiler
- you simply add the same@profile
decorator to a function. However, the same code differs in memory measurement from run to run, so getting accurate results seems elusive.This package is run with:
Beta Was this translation helpful? Give feedback.
All reactions