# ProfileEye - browser-based visualization frontend¶

ProfileEye is a broswer-based visualization frontend for gprof2dot and graphviz.

The former is a great tool for parsing profiler outputs and building relevant statstics, and the latter contains excellent graph-placement algorithms. Unfortunately, their outputs are static images. Modern Javascript libraries, e.g., d3.js, do a superior job at dynamic information-rich visualizations. ProfileEye combines these three, with the former two serving as a backend, and the latter serving as a frontend.

Contents:

## Requirements¶

This tool requires the following:

## Installation¶

Install the package via pip, as so:

$pip install ProfileEye  or, depending on your system’s policy on installation, something like so: $ sudo pip install ProfileEye


## Invocation¶

The invocation is the same as that of gprof2dot, except, at the end, pipe the output through profile_eye and redirect the result to an html file which you can view via a browswer.

For example, to use pgprof, run

/path/to/your/executable arg1 arg2
gprof path/to/your/executable | gprof2dot | profile_eye > profile_output.html


to use the Python profiler, run

python -m profile -o output.pstats path/to/your/script arg1 arg2
gprof2dot -f pstats output.pstats | profile_eye --file-colon_line-colon-label-format > profile_output.html


Note

Note the use of the --file-colon_line-colon-label-format flag, which tells the script that gprof2dot’s output is in the format <file>:<line>:<label>. Omitting this flag is possible, as so:

python -m profile -o output.pstats path/to/your/script arg1 arg2
gprof2dot -f pstats output.pstats | profile_eye > profile_output.html


but the output of the former is more informative than that of the latter (place the mouse on a node to see the file and line).

Tip

Use gprof2dot’s options (e.g., --node-thres) to control the intermediate output passed to the visualization.

Tip

For gprof, use gprof2dot’s -s (strip) option to shorten function names.

## Output¶

The output is something like the following figure (which is shown in a small form; see here a more realistic output).

View Type Calls Internal time Total time Fisheye Spline edges Straight edges

The primary display element is a combination of a bar chart and heat map. Each function is represented by an external empty bar, within which is an internal filled bar, both sharing the same color.

• The external empty bar represents the total time spent in the function (e.g., in the above, main has the widest bar).
• The internal filled bar represents the net time spent in the function, i.e., excluding the time spent in its children (e.g., in the above, a lot of time was spent in main, but nearly all of it was spent in its children).
• The bars colors form a heat map of the number of calls, with a brighter color indicating a larger number of calls (e.g., in the above, main was called far fewer times than hash_find_slot).

Tip

Placing the mouse over an element opens a tooltip with its exact time fractions and calls.

### The Calls View¶

The Calls view emphasizes the call flow between the different functions. Select it using the Calls radio item.

Edges are colored by the same #calls heat map as the function bars (a brighter edge means a larger number of calls); edges’ opacity is determined by the total amount of time spent on the call (a more opaque edge means a larger total amount of time spent on the call). (E.g., in the above, main-> update_goal_chain was followed few times, but represents a large fraction of the total time; conversely, lookup_file -> hash_find_item was followed more times, but represents a lower fraction of the total time).

Function calls generally run top down. Self or back edges (each indicating some type of recursion) are dashed (e.g., in the above, see pattern_search for a self edge, and eval -> eval_makefile for a back edge).

This view has two options:

• Fisheye mode introduces a fisheye distortion; in this mode items under the mouse will be spaced wider apart, for improved clarity.
• Spline edges vs Straight edges toggle curved spline lines (as calculated by graphviz) vs. simpler straight line.

### The Internal and Total Times Views¶

These views emphasizes the ranking of functions by internal or total time. Select it using the Internal time or Total time radio item.

Each of these views has a bar chart to the left, and two pie charts more to the right. The bar chart is ordered by the selected criteria, and includes a selection brush marked by a greyed rectangle. The pie charts more to the right show the fraction of time covered by the selection rectangle. (E.g., when selecting the Internal time call, you can see that the five functions with the highest internal time take together about 55 percent of all internal time.)

Tip

Modify the brush selection to see the effect on the pie charts. Alternatively, click on a pie slice to change the corresponding brush selection.

# Issues¶

Bug reports can be made at https://bitbucket.org/atavory/profileeye/issues.

# Module Reference¶

Note

This is a reference of the library backend of profile_eye. While you can use this directly, unless you’re sure of what you’re doing, you should probably use the utility version.

class profile_eye.DotPlainParser(file_colon_line_colon_label_format=False)[source]

A parser for dot’s output.

add(l)[source]

Feeds a line into the parser.

Args:
l: Line fed.
prepare_all()[source]

Prepares a dictionary of all parsed and processed data.

Returns:
A dictionary mapping ‘nodes’ to the nodes, and ‘edges’ to the edges.
profile_eye.gprof2dot_to_dot_plain(gprof2dot_output)[source]

Pipes gprof2dot output through dot with plain output specified.

Args:
gprof2dot_output: Bytes consisting of gprof2dot output.
Returns:
Output of dot -Tplain operating on gprof2dot_output.
profile_eye.render_parsed`(d)[source]

Renders HTML for parsed gprof2dot + dot output.

Args:
d: the results of a DotPlainParser’s prepare_all()
Returns:
A bytes object of HTML.