Back to index

moin  1.9.0~rc2
print_stats.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 # -*- coding: iso-8859-1 -*-
00003 """
00004     MoinMoin - Print statistics gathered by hotshot profiler
00005 
00006     Usage:
00007         print_stats.py statsfile
00008 
00009     Typical usage:
00010      1. Edit moin.py and activate the hotshot profiler, set profile file name
00011      2. Run moin.py
00012      3. Do some request, with a browser, script or ab
00013      4. Stop moin.py
00014      5. Run this tool: print_stats.py moin.prof
00015 
00016     Currently CGI and twisted also have a hotshot profiler integration.
00017 
00018     @copyright: 2005 by Thomas Waldmann (MoinMoin:ThomasWaldmann)
00019     @license: GNU GPL, see COPYING for details.
00020 """
00021 def run():
00022     import sys
00023     from hotshot import stats
00024 
00025     if len(sys.argv) != 2:
00026         print __doc__
00027         sys.exit()
00028 
00029     # Load and print stats
00030     s = stats.load(sys.argv[1])
00031     s.strip_dirs()
00032     s.sort_stats('cumulative', 'time', 'calls')
00033     s.print_stats(40)
00034     s.print_callers(40)
00035 
00036 if __name__ == "__main__":
00037     run()
00038