0
|
1 """
|
|
2 tweak rsn.py to run the profile module, and write the output to files
|
|
3 in profile/ with names that describe how you exercised the
|
|
4 program. then run this program to make files in profile/html/ for
|
|
5 easier viewing.
|
|
6 """
|
|
7
|
|
8 import pstats,glob,os,time,sys
|
|
9
|
|
10 allfiles = glob.glob("profile/*")
|
|
11 allfiles.remove('profile/html')
|
|
12 allfiles.sort()
|
|
13
|
|
14 header = "profile output from %s<p>" % (time.ctime())
|
|
15 for f in allfiles:
|
|
16 f=f[8:]
|
|
17 header = header+"<a href=%(f)s.html>%(f)s</a> | " % locals()
|
|
18
|
|
19 for profileoutput in allfiles:
|
|
20
|
|
21
|
|
22
|
|
23 s=pstats.Stats(profileoutput)
|
|
24
|
|
25 f=open("profile/html/%s.html" % profileoutput[8:],'w')
|
|
26 sys.stdout=f
|
|
27 print header,"<pre>"
|
|
28 s.sort_stats('cumulative').print_stats(15).print_callers(15)
|
|
29 print "</pre>"
|
|
30
|