File: show_stats.py

package info (click to toggle)
python-markdown2 2.4.11-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,104 kB
  • sloc: python: 5,416; perl: 1,493; php: 865; makefile: 34
file content (27 lines) | stat: -rw-r--r-- 550 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
"""
show_stats.py

Display results from profiling with hotshot.

Usage:
In module M.py, replace a call to function f with this code:

    import hotshot
    profiler = hotshot.Profile("%s.prof" % (__file__))
    profiler.runcall(f, *args)

and run from the command-line as
% python .../whatever.py args

To get the results, run this file:

% python .../show_stats.py .../whatever.py.prof
"""

import sys

import hotshot, hotshot.stats
stats = hotshot.stats.load(sys.argv[1])
stats.strip_dirs()
stats.sort_stats('time', 'calls')
stats.print_stats(20)