summaryrefslogtreecommitdiffstats
path: root/Tools/scripts/gprof2html.py
diff options
context:
space:
mode:
Diffstat (limited to 'Tools/scripts/gprof2html.py')
-rwxr-xr-xTools/scripts/gprof2html.py20
1 files changed, 11 insertions, 9 deletions
diff --git a/Tools/scripts/gprof2html.py b/Tools/scripts/gprof2html.py
index 4ca705c..b14def4 100755
--- a/Tools/scripts/gprof2html.py
+++ b/Tools/scripts/gprof2html.py
@@ -28,14 +28,7 @@ def add_escapes(filename):
for line in fp:
yield html.escape(line)
-
-def main():
- filename = "gprof.out"
- if sys.argv[1:]:
- filename = sys.argv[1]
- outputfilename = filename + ".html"
- input = add_escapes(filename)
- output = open(outputfilename, "w")
+def gprof2html(input, output, filename):
output.write(header % filename)
for line in input:
output.write(line)
@@ -78,7 +71,16 @@ def main():
part = '<a href="#call:%s">%s</a>' % (part, part)
output.write(part)
output.write(trailer)
- output.close()
+
+
+def main():
+ filename = "gprof.out"
+ if sys.argv[1:]:
+ filename = sys.argv[1]
+ outputfilename = filename + ".html"
+ input = add_escapes(filename)
+ with open(outputfilename, "w") as output:
+ gprof2html(input, output, filename)
webbrowser.open("file:" + os.path.abspath(outputfilename))
if __name__ == '__main__':