Staging
v0.5.1
v0.5.1
https://github.com/python/cpython
Revision 690ce9b353bc0a86d0886470adbaa50e813de3b8 authored by Senthil Kumaran on 05 May 2009, 18:41:13 UTC, committed by Senthil Kumaran on 05 May 2009, 18:41:13 UTC
This will address: a) urllib/ in py3k, b) urllib in py2x is addressed by issue918368. c) urllib2 in py2x was already addressed in Revision 43132.
1 parent 501927d
Tip revision: 690ce9b353bc0a86d0886470adbaa50e813de3b8 authored by Senthil Kumaran on 05 May 2009, 18:41:13 UTC
Fix for issue1153027, making Py3k changes similar to fix in issue918368.
Fix for issue1153027, making Py3k changes similar to fix in issue918368.
Tip revision: 690ce9b
gprof2html.py
#! /usr/bin/env python2.3
"""Transform gprof(1) output into useful HTML."""
import re, os, sys, cgi, webbrowser
header = """\
<html>
<head>
<title>gprof output (%s)</title>
</head>
<body>
<pre>
"""
trailer = """\
</pre>
</body>
</html>
"""
def add_escapes(input):
for line in input:
yield cgi.escape(line)
def main():
filename = "gprof.out"
if sys.argv[1:]:
filename = sys.argv[1]
outputfilename = filename + ".html"
input = add_escapes(file(filename))
output = file(outputfilename, "w")
output.write(header % filename)
for line in input:
output.write(line)
if line.startswith(" time"):
break
labels = {}
for line in input:
m = re.match(r"(.* )(\w+)\n", line)
if not m:
output.write(line)
break
stuff, fname = m.group(1, 2)
labels[fname] = fname
output.write('%s<a name="flat:%s" href="#call:%s">%s</a>\n' %
(stuff, fname, fname, fname))
for line in input:
output.write(line)
if line.startswith("index % time"):
break
for line in input:
m = re.match(r"(.* )(\w+)(( <cycle.*>)? \[\d+\])\n", line)
if not m:
output.write(line)
if line.startswith("Index by function name"):
break
continue
prefix, fname, suffix = m.group(1, 2, 3)
if fname not in labels:
output.write(line)
continue
if line.startswith("["):
output.write('%s<a name="call:%s" href="#flat:%s">%s</a>%s\n' %
(prefix, fname, fname, fname, suffix))
else:
output.write('%s<a href="#call:%s">%s</a>%s\n' %
(prefix, fname, fname, suffix))
for line in input:
for part in re.findall(r"(\w+(?:\.c)?|\W+)", line):
if part in labels:
part = '<a href="#call:%s">%s</a>' % (part, part)
output.write(part)
output.write(trailer)
output.close()
webbrowser.open("file:" + os.path.abspath(outputfilename))
if __name__ == '__main__':
main()
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...