Skip to content

Performance Profiling #7203

Answered by Theelx
Flamenate asked this question in General
Jul 11, 2021 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

For CPU profiling, line-by-line, I'd use line_profiler. The official library, which can be installed off PyPi with pip install line_profiler, doesn't have support for generating profiler results every x seconds, it only generates profiler results when the bot stops. I use kernprof -lvz (file name here, like run.py). That's why I made a fork that has a command line flag to output to a file every x seconds. With this, you can do something like kernprof -lvzi 15 (file name here), and it'll output results to a file every 15 seconds. You can view profiling results with python3 -m line_profiler ./run.py.lprof (replace run.py with your file name, ending with a .lprof suffix).

To profile a specif…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Flamenate
Comment options

Answer selected by Flamenate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants