Created
April 13, 2013 00:47
-
-
Save adambarthelson/5376300 to your computer and use it in GitHub Desktop.
Efficiency breakdown of Python files.
This file contains hidden or 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
import os | |
import pstats | |
def testeff(path): | |
try: | |
os.remove('rep.prof') | |
except: | |
os.system('python -m cProfile -o rep.prof {}'.format(path)) | |
p = pstats.Stats('rep.prof') | |
p.sort_stats('cumulative').print_stats(10) | |
os.remove('rep.prof') | |
else: | |
os.system('python -m cProfile -o rep.prof {}'.format(path)) | |
p = pstats.Stats('rep.prof') | |
p.sort_stats('cumulative').print_stats(10) | |
os.remove('rep.prof') | |
path = str(raw_input('File path: ')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment