summaryrefslogtreecommitdiff
path: root/sys/src/cmd/python/Tools/scripts/gprof2html.py
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2021-06-14 00:00:37 +0000
committerOri Bernstein <ori@eigenstate.org>2021-06-14 00:00:37 +0000
commita73a964e51247ed169d322c725a3a18859f109a3 (patch)
tree3f752d117274d444bda44e85609aeac1acf313f3 /sys/src/cmd/python/Tools/scripts/gprof2html.py
parente64efe273fcb921a61bf27d33b230c4e64fcd425 (diff)
python, hg: tow outside the environment.
they've served us well, and can ride off into the sunset.
Diffstat (limited to 'sys/src/cmd/python/Tools/scripts/gprof2html.py')
-rwxr-xr-xsys/src/cmd/python/Tools/scripts/gprof2html.py79
1 files changed, 0 insertions, 79 deletions
diff --git a/sys/src/cmd/python/Tools/scripts/gprof2html.py b/sys/src/cmd/python/Tools/scripts/gprof2html.py
deleted file mode 100755
index cb01c2ce6..000000000
--- a/sys/src/cmd/python/Tools/scripts/gprof2html.py
+++ /dev/null
@@ -1,79 +0,0 @@
-#! /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+)(( &lt;cycle.*&gt;)? \[\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()