Skip to content

Commit

Permalink
fix showing comparison on the edges
Browse files Browse the repository at this point in the history
  • Loading branch information
KasiaS999 authored and jrfonseca committed Jul 20, 2024
1 parent 7e1bb49 commit 27dbac9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ It can:
* use an heuristic to propagate time inside mutually recursive functions;
* use color efficiently to draw attention to hot-spots;
* work on any platform where Python and Graphviz is available, i.e, virtually anywhere;
* compare two graphs with identical structures for the analysis of performance metrics such as time or function calls.
* compare two graphs with almost identical structures for the analysis of performance metrics such as time or function calls.

**If you want an interactive viewer for the graphs generated by _gprof2dot_, check [xdot.py](https://github.com/jrfonseca/xdot.py).**

Expand Down Expand Up @@ -131,7 +131,7 @@ Options:
variety to lower percentages
-p FILTER_PATHS, --path=FILTER_PATHS
Filter all modules not in a specified path
--compare Compare two graphs with identical structure. With this
--compare Compare two graphs with almost identical structure. With this
option two files should be provided.gprof2dot.py
[options] --compare [file1] [file2] ...
--compare-tolerance=TOLERANCE
Expand Down
13 changes: 9 additions & 4 deletions gprof2dot.py
Original file line number Diff line number Diff line change
Expand Up @@ -3288,8 +3288,7 @@ def graphs_compare(self, profile1, profile2, theme, options):
self.attr('node', fontname=fontname, style=nodestyle, fontcolor=fontcolor, width=0, height=0)
self.attr('edge', fontname=fontname)

functions2 = {function.name: function
for _, function in sorted_iteritems(profile2.functions)}
functions2 = {function.name: function for _, function in sorted_iteritems(profile2.functions)}

for _, function1 in sorted_iteritems(profile1.functions):
labels = []
Expand Down Expand Up @@ -3403,10 +3402,16 @@ def graphs_compare(self, profile1, profile2, theme, options):
)

calls2 = {call.callee_id: call for _, call in sorted_iteritems(function2.calls)}
functions_by_id1 = {function.id: function for _, function in sorted_iteritems(profile1.functions)}

for _, call1 in sorted_iteritems(function1.calls):
labels = []
try:
call2 = calls2[call1.callee_id]
# if profiles do not have identical setups, callee_id will not be identical either
call_id1 = call1.callee_id
call_name = functions_by_id1[call_id1].name
call_id2 = functions2[call_name].id
call2 = calls2[call_id2]
for event in self.show_edge_events:
if event in call1.events:
label = f'{event.format(call1[event])} / {event.format(call2[event])}'
Expand Down Expand Up @@ -3725,7 +3730,7 @@ def main(argv=sys.argv[1:]):
'--compare',
action="store_true",
dest="compare", default=False,
help="Compare two graphs with identical structure. With this option two files should be provided."
help="Compare two graphs with almost identical structure. With this option two files should be provided."
"gprof2dot.py [options] --compare [file1] [file2] ...")
optparser.add_option(
'--compare-tolerance',
Expand Down

0 comments on commit 27dbac9

Please sign in to comment.