# profile_stats5.py
# Written by Todd Wareham for CS 2500
"""
This script illustrates an elementary profiling analysis of the runtimes of 
 the various functions in statistics computation script stats5.py.
 
This analysis is implemented using the profile and pstats modules.
 """

import sys
import stats5
import profile
import pstats


if len(sys.argv) != 2:
    print "usage: profile_stats5 <stats5-script>"
    sys.exit(1)

profile.run("stats5.interpret(\"%s\")" % (sys.argv[1],), 
            sys.argv[1] + ".prof")
s = pstats.Stats(sys.argv[1] + ".prof")
s.sort_stats("calls")
s.print_stats()

