Skip to content

Commit

Permalink
ClangSimilarityBear: Don't use pool
Browse files Browse the repository at this point in the history
The tests are now faster and the code is less complex. I'm not convinced
that the pool is a real advantage so until there is no data on this
let's go without it.
  • Loading branch information
sils committed Jun 11, 2015
1 parent 87c13b1 commit acae07e
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions bears/codeclone_detection/ClangSimilarityBear.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from itertools import combinations
import multiprocessing

from coalib.misc.StringConverter import StringConverter
from coalib.processes.Processing import get_cpu_count
from coalib.results.HiddenResult import HiddenResult
from coalib.settings.Setting import typed_dict
from coalib.bears.GlobalBear import GlobalBear
Expand Down Expand Up @@ -101,21 +99,14 @@ def run(self,
lambda prog: self.debug("{:2.4f}%...".format(prog)))

self.debug("Calculating differences...")
# Code clone detection may take ages for a larger code basis. It is
# highly probable, that no other bears are running in parallel,
# thus we do parallel execution within this bear.
pool = multiprocessing.Pool(get_cpu_count())

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)):
for i, elem in enumerate(map(get_difference, function_combinations)):
if i % 1000 == 0:
self.debug("{:2.4f}%...".format(100*i/combination_length))
differences.append(elem)
Expand Down

0 comments on commit acae07e

Please sign in to comment.