Skip to content

Dot Exporter and Write to a file#618

Merged
JonasKlauke merged 4 commits intodevelopfrom
DotExporter
Jun 21, 2023
Merged

Dot Exporter and Write to a file#618
JonasKlauke merged 4 commits intodevelopfrom
DotExporter

Conversation

@palaniappan1
Copy link
Copy Markdown
Collaborator

No description provided.

@codecov
Copy link
Copy Markdown

codecov bot commented Jun 6, 2023

Codecov Report

Patch coverage: 93.75% and project coverage change: +0.06 🎉

Comparison is base (8ac5289) 64.33% compared to head (6c7ce1f) 64.39%.

Additional details and impacted files
@@              Coverage Diff              @@
##             develop     #618      +/-   ##
=============================================
+ Coverage      64.33%   64.39%   +0.06%     
- Complexity      3290     3297       +7     
=============================================
  Files            311      311              
  Lines          14709    14741      +32     
  Branches        2450     2450              
=============================================
+ Hits            9463     9493      +30     
- Misses          4359     4361       +2     
  Partials         887      887              
Impacted Files Coverage Δ
...ain/java/sootup/callgraph/GraphBasedCallGraph.java 94.84% <93.75%> (-0.54%) ⬇️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

.append(";\n");
}
// Sort the callGraph
String sortedCallGraph = sortCallGraph(dotFormatBuilder.toString());
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont sort the string. Sort the edges in the call graph it is way easier

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wasting execution time to extract strings if we have already ways to get them before we call tostring on the method signature

1. Removed the file write and now the method returns the DotFormat string
2. All methodsignatures are enclosed in ""
3.Unwanted imports removed
4.Sorted based on edges and parameter comparison added
String sortedCallGraph = sortCallGraph(dotFormatBuilder.toString());

// Using only one string builder, so deleting everything and adding the sorted callgraph
dotFormatBuilder.delete(0, dotFormatBuilder.capacity());
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't do this.
Instead just return the string concatination
"strict digraph ObjectGraph {\n" + sortedCallgraph + "}"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deleting the string builder seems unnecessary complex, and it might waste execution time

* @param dotOutput
* @return
*/
public String sortCallGraph(String dotOutput) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you still use this method?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

your edges are already kind of sorted. why sort them again?

graph.edgeSet().stream()
.sorted(
Comparator.comparing(
(Edge edge) -> graph.getEdgeSource(edge).toString(), Comparator.naturalOrder())
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont sort the entire signature.
otherwise the order will be class name , return type, method name and then parameter.
but we dont want that the return type highly effects the order. So you have to compare the parts of the method signatures

1. sortCallGraph() method removed
2. The comparator is written in such a way because we don't have access to methodSignature at first like in toString() method.
@palaniappan1 palaniappan1 linked an issue Jun 21, 2023 that may be closed by this pull request
Copy link
Copy Markdown
Collaborator

@JonasKlauke JonasKlauke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work 👍

@JonasKlauke JonasKlauke merged commit 59dfdee into develop Jun 21, 2023
@JonasKlauke JonasKlauke deleted the DotExporter branch June 21, 2023 11:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dotexporter for call graphs

3 participants