Skip to content

Commit

Permalink
WIP: Show progress
Browse files Browse the repository at this point in the history
  • Loading branch information
sils committed May 21, 2015
1 parent 307fa6c commit 83d9586
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
17 changes: 13 additions & 4 deletions bears/codeclone_detection/ClangSimilarityBear.py
Expand Up @@ -82,9 +82,18 @@ def run(self,
# thus we do parallel execution within this bear.
pool = multiprocessing.Pool(get_cpu_count())

differences = pool.map(
get_difference,
[(f1, f2, count_matrices)
for f1, f2 in combinations(count_matrices, 2)])
differences = []
function_count = len(count_matrices)
# Thats n over 2, hardcoded to simplify calculation
combination_length = function_count * (function_count-1) / 2
function_combinations = [(f1, f2, count_matrices)
for f1, f2 in combinations(count_matrices, 2)]

for i, elem in enumerate(pool.imap_unordered(get_difference,
function_combinations,
chunksize=100)):
if i % 1000 == 0:
self.debug("{:2.4f}%".format(100*i/combination_length))
differences.append(elem)

return [HiddenResult(self.__class__.__name__, differences)]
4 changes: 4 additions & 0 deletions bears/codeclone_detection/CloneDetectionRoutines.py
Expand Up @@ -32,8 +32,12 @@ def get_count_matrices(count_vector_creator, filenames):
objects with variable names as key as content.
"""
result = {}
i = 0
maxlen = len(filenames)

for filename in filenames:
i += 1
print("{:2.4f}%".format(100*(i/maxlen)))
count_dict = count_vector_creator.get_vectors_for_file(filename)
for function in count_dict:
if not exclude_function(count_dict[function]):
Expand Down

0 comments on commit 83d9586

Please sign in to comment.