Skip to content

Commit

Permalink
Merge branch 'optimize-call-graph' into 'develop'
Browse files Browse the repository at this point in the history
cache call commit graph

See merge request persper/code-analytics!123
  • Loading branch information
merico-test committed Jun 13, 2019
2 parents cfed84c + 1983d2d commit 78cd621
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions persper/analytics/analyzer2.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def __init__(self, repositoryRoot: str, graphServer: GraphServer,
self._skip_rewind_diff = skip_rewind_diff
self._monolithic_commit_lines_threshold = monolithic_commit_lines_threshold
self._monolithic_file_bytes_threshold = monolithic_file_bytes_threshold
self._call_commit_graph = None

def __getstate__(self):
state = self.__dict__.copy()
Expand Down Expand Up @@ -110,8 +111,16 @@ def firstParentOnly(self, value: bool):

@property
def graph(self):
return self._graphServer.get_graph()

# When starting the analysis,set self._call_commit_graph to None, we can ensure that the graph is the latest call commit graph version.
if self._call_commit_graph is None:
# retry 10 times when get graph from graph server
for i in range(10):
ccg = self._graphServer.get_graph()
break
else:
raise Exception('get graph is failed')
self._call_commit_graph = ccg
return self._call_commit_graph
@property
def visitedCommits(self) -> Set[str]:
"""
Expand Down Expand Up @@ -151,6 +160,7 @@ def compute_modularity(self):
return self.graph.compute_modularity()

async def analyze(self, maxAnalyzedCommits=None, suppressStdOutLogs=False):
self._call_commit_graph = None
commitSpec = self._terminalCommit
if self._originCommit:
commitSpec = self._originCommit.hexsha + ".." + self._terminalCommit.hexsha
Expand Down

0 comments on commit 78cd621

Please sign in to comment.