Back to index

python3.2  3.2.2
Functions | Variables
gprof2html Namespace Reference

Functions

def add_escapes
def main

Variables

string header
string trailer

Function Documentation

def gprof2html.add_escapes (   input)

Definition at line 22 of file gprof2html.py.

00022 
00023 def add_escapes(input):
00024     for line in input:
00025         yield cgi.escape(line)

Here is the call graph for this function:

Here is the caller graph for this function:

def gprof2html.main ( void  )

Definition at line 26 of file gprof2html.py.

00026 
00027 def main():
00028     filename = "gprof.out"
00029     if sys.argv[1:]:
00030         filename = sys.argv[1]
00031     outputfilename = filename + ".html"
00032     input = add_escapes(file(filename))
00033     output = file(outputfilename, "w")
00034     output.write(header % filename)
00035     for line in input:
00036         output.write(line)
00037         if line.startswith(" time"):
00038             break
00039     labels = {}
00040     for line in input:
00041         m = re.match(r"(.*  )(\w+)\n", line)
00042         if not m:
00043             output.write(line)
00044             break
00045         stuff, fname = m.group(1, 2)
00046         labels[fname] = fname
00047         output.write('%s<a name="flat:%s" href="#call:%s">%s</a>\n' %
00048                      (stuff, fname, fname, fname))
00049     for line in input:
00050         output.write(line)
00051         if line.startswith("index % time"):
00052             break
00053     for line in input:
00054         m = re.match(r"(.*  )(\w+)(( &lt;cycle.*&gt;)? \[\d+\])\n", line)
00055         if not m:
00056             output.write(line)
00057             if line.startswith("Index by function name"):
00058                 break
00059             continue
00060         prefix, fname, suffix = m.group(1, 2, 3)
00061         if fname not in labels:
00062             output.write(line)
00063             continue
00064         if line.startswith("["):
00065             output.write('%s<a name="call:%s" href="#flat:%s">%s</a>%s\n' %
00066                          (prefix, fname, fname, fname, suffix))
00067         else:
00068             output.write('%s<a href="#call:%s">%s</a>%s\n' %
00069                          (prefix, fname, fname, suffix))
00070     for line in input:
00071         for part in re.findall(r"(\w+(?:\.c)?|\W+)", line):
00072             if part in labels:
00073                 part = '<a href="#call:%s">%s</a>' % (part, part)
00074             output.write(part)
00075     output.write(trailer)
00076     output.close()
00077     webbrowser.open("file:" + os.path.abspath(outputfilename))

Here is the call graph for this function:


Variable Documentation

Initial value:
00001 """\
00002 <html>
00003 <head>
00004   <title>gprof output (%s)</title>
00005 </head>
00006 <body>
00007 <pre>
00008 """

Definition at line 7 of file gprof2html.py.

Initial value:
00001 """\
00002 </pre>
00003 </body>
00004 </html>
00005 """

Definition at line 16 of file gprof2html.py.