summaryrefslogtreecommitdiff
path: root/scripts/profiling/storage/profile-format.py
blob: 262a52ab965eddadea704cc8cef1d6e0e37de1e1 (plain)
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
28
29
#!/usr/bin/python

import argparse
import pstats


def parse_args():
    # parse command line
    parser = argparse.ArgumentParser()
    parser.add_argument(
        '-f', dest='statsfiles', action='append', required=True,
        help='a stats file')
    args = parser.parse_args()
    return args.statsfiles


def format_stats(statsfiles):
    for f in statsfiles:
        ps = pstats.Stats(f)
        ps.strip_dirs()
        ps.sort_stats('time')
        ps.print_stats()
        ps.sort_stats('cumulative')
        ps.print_stats()


if __name__ == '__main__':
    statsfiles = parse_args()
    format_stats(statsfiles)