gprof2dot module

Generate a dot graph from the output of several profilers.

class gprof2dot.AXEParser(fp)[source]

Bases: gprof2dot.Parser

Parser for VTune Amplifier XE 2013 gprof-cc report output.

parse()[source]
parse_cg()[source]

Parse the call graph.

parse_cg_entry(lines)[source]
parse_cycle_entry(lines)[source]
parse_function_entry(lines)[source]
readline()[source]
translate(mo)[source]

Extract a structure from a match object, while translating the types in the process.

class gprof2dot.Call(callee_id)[source]

Bases: gprof2dot.Object

A call between functions.

There should be at most one call object for every pair of functions.

class gprof2dot.CallgrindParser(infile)[source]

Bases: gprof2dot.LineParser

Parser for valgrind’s callgrind tool.

See also: - http://valgrind.org/docs/manual/cl-format.html

get_callee()[source]
get_function()[source]
make_function(module, filename, name)[source]
parse()[source]
parse_association_spec()[source]
parse_body_line()[source]
parse_comment()[source]
parse_cost_line(calls=None)[source]
parse_cost_line_def()[source]
parse_cost_summary()[source]
parse_description()[source]
parse_empty()[source]
parse_event_specification()[source]
parse_header_line()[source]
parse_key(key)[source]
parse_keys(keys)[source]
parse_part()[source]
parse_part_detail()[source]
parse_position_spec()[source]
class gprof2dot.Cycle[source]

Bases: gprof2dot.Object

A cycle made from recursive function calls.

add_function(function)[source]
class gprof2dot.DotWriter(fp)[source]

Writer for the DOT language.

See also: - “The DOT Language” specification

attr(what, **attrs)[source]
attr_list(attrs)[source]
begin_graph()[source]
color(rgb)[source]
edge(src, dst, **attrs)[source]
end_graph()[source]
escape(s)[source]
graph(profile, theme)[source]
id(id)[source]
node(node, **attrs)[source]
show_edge_events = [<gprof2dot.Event object at 0x7fb65bfc0690>, <gprof2dot.Event object at 0x7fb65f11c290>]
show_function_events = [<gprof2dot.Event object at 0x7fb65bfc0690>, <gprof2dot.Event object at 0x7fb65bfc0790>]
strip = False
wrap = False
wrap_function_name(name)[source]

Split the function name on multiple lines.

write(s)[source]
class gprof2dot.Event(name, null, aggregator, formatter=<type 'str'>)[source]

Bases: object

Describe a kind of event, and its basic operations.

aggregate(val1, val2)[source]

Aggregate two event values.

format(val)[source]

Format an event value.

null()[source]
class gprof2dot.Function(id, name)[source]

Bases: gprof2dot.Object

A function.

add_call(call)[source]
get_call(callee_id)[source]
stripped_name()[source]

Remove extraneous information from C++ demangled function names.

class gprof2dot.GprofParser(fp)[source]

Bases: gprof2dot.Parser

Parser for GNU gprof output.

See also: - Chapter “Interpreting gprof’s Output” from the GNU gprof manual

parse()[source]
parse_cg()[source]

Parse the call graph.

parse_cg_entry(lines)[source]
parse_cycle_entry(lines)[source]
parse_function_entry(lines)[source]
readline()[source]
translate(mo)[source]

Extract a structure from a match object, while translating the types in the process.

class gprof2dot.HProfParser(infile)[source]

Bases: gprof2dot.LineParser

Parser for java hprof output

See also: - http://java.sun.com/developer/technicalArticles/Programming/HPROF.html

parse()[source]
parse_samples()[source]
parse_trace()[source]
parse_traces()[source]
trace_id_re = <_sre.SRE_Pattern object at 0x7fb65bab83f0>
trace_re = <_sre.SRE_Pattern object at 0x7fb65bf84030>
class gprof2dot.JsonParser(stream)[source]

Bases: gprof2dot.Parser

Parser for a custom JSON representation of profile data.

See schema.json for details.

parse()[source]
class gprof2dot.LineParser(stream)[source]

Bases: gprof2dot.Parser

Base class for parsers that read line-based formats.

consume()[source]
eof()[source]
lookahead()[source]
readline()[source]
class gprof2dot.Object(events=None)[source]

Bases: object

Base class for all objects in profile which can store events.

class gprof2dot.OprofileParser(infile)[source]

Bases: gprof2dot.LineParser

Parser for oprofile callgraph output.

See also: - http://oprofile.sourceforge.net/doc/opreport.html#opreport-callgraph

add_entry(callers, function, callees)[source]
match_header()[source]
match_primary()[source]
match_secondary()[source]
match_separator()[source]
parse()[source]
parse_entry()[source]
parse_header()[source]
parse_subentries()[source]
parse_subentry()[source]
skip_separator()[source]
update_subentries_dict(totals, partials)[source]
exception gprof2dot.ParseError(msg, line)[source]

Bases: exceptions.Exception

Raised when parsing to signal mismatches.

class gprof2dot.Parser[source]

Parser interface.

multipleInput = False
parse()[source]
stdinInput = True
class gprof2dot.PerfParser(infile)[source]

Bases: gprof2dot.LineParser

Parser for linux perf callgraph output.

It expects output generated with

perf record -g perf script | gprof2dot.py –format=perf
call_re = <_sre.SRE_Pattern object at 0x7fb65f121030>
parse()[source]
parse_call()[source]
parse_callchain()[source]
parse_event()[source]
readline()[source]
class gprof2dot.Profile[source]

Bases: gprof2dot.Object

The whole profile.

add_cycle(cycle)[source]
add_function(function)[source]
aggregate(event)[source]

Aggregate an event for the whole profile.

call_ratios(event)[source]
dump()[source]
find_cycles()[source]

Find cycles using Tarjan’s strongly connected components algorithm.

getFunctionId(funcName)[source]
integrate(outevent, inevent)[source]

Propagate function time ratio along the function calls.

Must be called after finding the cycles.

See also: - http://citeseer.ist.psu.edu/graham82gprof.html

prune(node_thres, edge_thres)[source]

Prune the profile

prune_leaf(leaf)[source]
prune_root(root)[source]
ratio(outevent, inevent)[source]
validate()[source]

Validate the edges.

class gprof2dot.PstatsParser(*filename)[source]

Parser python profiling statistics saved with te pstats module.

get_function(key)[source]
get_function_name(key)[source]
multipleInput = True
parse()[source]
stdinInput = False
class gprof2dot.SleepyParser(filename)[source]

Bases: gprof2dot.Parser

Parser for GNU gprof output.

See also: - http://www.codersnotes.com/sleepy/ - http://sleepygraph.sourceforge.net/

openEntry(name)[source]
parse()[source]
parse_callstacks()[source]
parse_symbols()[source]
stdinInput = False
class gprof2dot.Struct(attrs=None)[source]

Masquerade a dictionary with a structure-like behavior.

class gprof2dot.SysprofParser(stream)[source]

Bases: gprof2dot.XmlParser

build_profile(objects, nodes)[source]
parse()[source]
parse_item(name)[source]
parse_items(name)[source]
parse_value(tag)[source]
parse_values()[source]
class gprof2dot.Theme(bgcolor=(0.0, 0.0, 1.0), mincolor=(0.0, 0.0, 0.0), maxcolor=(0.0, 0.0, 1.0), fontname='Arial', fontcolor='white', nodestyle='filled', minfontsize=10.0, maxfontsize=10.0, minpenwidth=0.5, maxpenwidth=4.0, gamma=2.2, skew=1.0)[source]
color(weight)[source]
edge_arrowsize(weight)[source]
edge_color(weight)[source]
edge_fontsize(weight)[source]
edge_penwidth(weight)[source]
fontsize(weight)[source]
graph_bgcolor()[source]
graph_fontcolor()[source]
graph_fontname()[source]
graph_fontsize()[source]
hsl_to_rgb(h, s, l)[source]

Convert a color from HSL color-model to RGB.

See also: - http://www.w3.org/TR/css3-color/#hsl-color

node_bgcolor(weight)[source]
node_fgcolor(weight)[source]
node_fontsize(weight)[source]
node_style()[source]
exception gprof2dot.UndefinedEvent(event)[source]

Bases: exceptions.Exception

Raised when attempting to get an event which is undefined.

class gprof2dot.XPerfParser(stream)[source]

Bases: gprof2dot.Parser

Parser for CSVs generted by XPerf, from Microsoft Windows Performance Tools.

get_function(process, symbol)[source]
parse()[source]
parse_header(row)[source]
parse_row(row)[source]
class gprof2dot.XmlParser(fp)[source]

Bases: gprof2dot.Parser

Base XML document parser.

character_data(strip=True)[source]
consume()[source]
element_end(name)[source]
element_start(name)[source]
match_element_end(name)[source]
match_element_start(name)[source]
class gprof2dot.XmlToken(type, name_or_data, attrs=None, line=None, column=None)[source]
exception gprof2dot.XmlTokenMismatch(expected, found)[source]

Bases: exceptions.Exception

class gprof2dot.XmlTokenizer(fp, skip_ws=True)[source]

Expat based XML tokenizer.

finish_character_data()[source]
handle_character_data(data)[source]
handle_element_end(name)[source]
handle_element_start(name, attributes)[source]
next()[source]
pos()[source]
gprof2dot.add(a, b)[source]
gprof2dot.compat_iteritems(x)[source]
gprof2dot.compat_itervalues(x)[source]
gprof2dot.compat_keys(x)[source]
gprof2dot.fail(a, b)[source]
gprof2dot.main()[source]

Main program.

gprof2dot.naturalJoin(values)[source]
gprof2dot.percentage(p)[source]
gprof2dot.ratio(numerator, denominator)[source]
gprof2dot.sorted_iteritems(d)[source]
gprof2dot.times(x)[source]