-
Notifications
You must be signed in to change notification settings - Fork 182
Profiling
FW edited this page Mar 3, 2019
·
2 revisions
Profiling gives you a detailed breakdown of execution times, allowing you to identify bottlenecks in your bot. You can create a profile by running in your command line:
py -3.7 -O -m cProfile -o profile_name.prof bot_main.py
This will run the bot from its bot_main.py
and save a profile file profile_name.prof
. To view these profiles, I recommend snakeviz
. You can read about it here and get it here or install it with pip (pip install snakeviz
).
In you command line, you can then let snakeviz visualize the profile with the command snakeviz profile_name.prof
.
To make profiling easier, I recommend to create a benchmark.py
that you just need to run and the snakeviz profile gets drawn once the game is done.
# benchmark.py
import os
os.system("py -3.7 -O -m cProfile -o profile_name.prof main.py")
os.system("snakeviz profile_name.prof")