# profile_matm3.py
# Written by Todd Wareham for CS 2500
"""
This script illustrates an elementary profiling analysis of the runtimes of 
 the various functions in matrix manipulation script matm3.py.
 
This analysis is implemented using the profile and pstats modules.
 """

import sys
import matm3
import profile
import pstats


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

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

