Last active
August 29, 2015 14:20
-
-
Save mirekfranc/69f167936790882217e5 to your computer and use it in GitHub Desktop.
How to profile and debug python script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################################################## | |
# profiler: | |
# https://docs.python.org/2/library/profile.html | |
# python -mcProfile -o profiler.out ./something.py | |
### profile.py ### | |
import pstats | |
p = pstats.Stats('profiler.out') | |
p.sort_stats('cumtime').print_stats(20) | |
p.sort_stats('time').print_stats(20) | |
p.print_stats ('lambda|filter') | |
# python profile.py | |
################################################## | |
# debugger: | |
# https://docs.python.org/2/library/pdb.html | |
# python -mpdb ./something.py | |
# help | |
# b main | |
# n | |
# pp options | |
# bt | |
# c | |
################################################## | |
# code coverage: | |
# python -mtrace --count ./something.py | |
# coverage in something.cover |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment