Created
April 12, 2012 16:14
-
-
Save taoliu/2368738 to your computer and use it in GitHub Desktop.
print stats of Python profile
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
#!/usr/bin/env python | |
# Time-stamp: <2012-04-12 12:12:53 Tao Liu> | |
import sys | |
import pstats | |
# ------------------------------------ | |
# Main function | |
# ------------------------------------ | |
def main(): | |
if len(sys.argv) < 3: | |
sys.stderr.write("need 2 paras: %s <prof file> <time|calls|cumulative|...>\n" % sys.argv[0]) | |
sys.exit(1) | |
p = pstats.Stats(sys.argv[1]) | |
sort_term = sys.argv[2] | |
p.strip_dirs().sort_stats(sort_term).print_stats(20) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment