From a00b2a9b6114f6bdc416cf0fc4a3c3b212260b50 Mon Sep 17 00:00:00 2001 From: mimic Date: Fri, 6 Mar 2020 15:17:26 +0100 Subject: [PATCH] new compare visualization --- .../serval/fixminer/jobs/CompareTrees.java | 128 ++++++++++-------- src/main/resource/MF0012.local.app.properties | 19 +++ 2 files changed, 92 insertions(+), 55 deletions(-) create mode 100644 src/main/resource/MF0012.local.app.properties diff --git a/src/main/java/edu/lu/uni/serval/fixminer/jobs/CompareTrees.java b/src/main/java/edu/lu/uni/serval/fixminer/jobs/CompareTrees.java index 9ef0d42..cd3f231 100755 --- a/src/main/java/edu/lu/uni/serval/fixminer/jobs/CompareTrees.java +++ b/src/main/java/edu/lu/uni/serval/fixminer/jobs/CompareTrees.java @@ -1,5 +1,6 @@ package edu.lu.uni.serval.fixminer.jobs; +import edu.lu.uni.serval.fixminer.ediff.EDiffHunkParser; import edu.lu.uni.serval.utils.CallShell; import edu.lu.uni.serval.utils.EDiffHelper; import edu.lu.uni.serval.utils.PoolBuilder; @@ -17,6 +18,7 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.stream.Collectors; +import java.util.stream.IntStream; /** @@ -57,38 +59,54 @@ public class CompareTrees { // List listOfPairs = AkkaTreeParser.files2compare(outerPool); - ArrayList samePairs = new ArrayList<>(); +// ArrayList samePairs = new ArrayList<>(); ArrayList errorPairs = new ArrayList<>(); - Integer numberOfWorkers = Integer.valueOf(numOfWorkers); - final ExecutorService executor = Executors.newWorkStealingPool(numberOfWorkers); - ArrayList> results = new ArrayList>(); - for (int i = 1; i future = executor.submit(new RunnableCompare(job, errorPairs, filenames, outerPool, i)); - results.add(future); +// Integer numberOfWorkers = Integer.valueOf(numOfWorkers); +// final ExecutorService executor = Executors.newWorkStealingPool(numberOfWorkers); + Long compare; + try (Jedis inner = outerPool.getResource()) { + compare = inner.scard("compare"); } - for (Future future : ProgressBar.wrap(results, "Comparing")){ -// for (Future future:results){ - try { - // wait for task to complete - future.get(); + IntStream stream = IntStream.range(0, compare.intValue()); - } catch (InterruptedException e) { + ProgressBar.wrap(stream. + parallel(),"Task"). - e.printStackTrace(); - } catch (ExecutionException e) { + forEach(m -> + { + newCoreCompare(job, errorPairs, filenames, outerPool); + } + ); - e.printStackTrace(); - } -// finally { -// executor.shutdownNow(); +// +// ArrayList> results = new ArrayList>(); +// for (int i = 0; i future = executor.submit(new RunnableCompare(job, errorPairs, filenames, outerPool, i)); +// results.add(future); +// } +// for (Future future : ProgressBar.wrap(results, "Comparing")){ +//// for (Future future:results){ +// try { +// // wait for task to complete +// future.get(); +// +// } catch (InterruptedException e) { +// +// e.printStackTrace(); +// } catch (ExecutionException e) { +// +// e.printStackTrace(); // } - } - executor.shutdownNow(); +//// finally { +//// executor.shutdownNow(); +//// } +// } +// executor.shutdownNow(); @@ -97,36 +115,36 @@ public class CompareTrees { } - public static class RunnableCompare implements Runnable { - String job; - ArrayList errorPairs; - HashMap filenames; - JedisPool outerPool; - Integer threadID; - - public RunnableCompare(String treeType,ArrayList errorPairs, HashMap filenames,JedisPool outerPool,Integer threadID) { - this.job = treeType; - this.errorPairs = errorPairs; - this.filenames = filenames; - this.outerPool = outerPool; - this.threadID = threadID; - } - - @Override - public void run() { -// int dbsize = 1; - boolean stop = true; - while(stop) { -// try (Jedis outer = outerPool.getResource()) { -// dbsize = Math.toIntExact(outer.scard("compare")); -// } -// if (dbsize != 0){ - stop = newCoreCompare(job, errorPairs, filenames, outerPool); -// } - } - log.info("Completed worker {}",threadID); - } - } +// public static class RunnableCompare implements Runnable { +// String job; +// ArrayList errorPairs; +// HashMap filenames; +// JedisPool outerPool; +// Integer threadID; +// +// public RunnableCompare(String treeType,ArrayList errorPairs, HashMap filenames,JedisPool outerPool,Integer threadID) { +// this.job = treeType; +// this.errorPairs = errorPairs; +// this.filenames = filenames; +// this.outerPool = outerPool; +// this.threadID = threadID; +// } +// +// @Override +// public void run() { +//// int dbsize = 1; +// boolean stop = true; +// while(stop) { +//// try (Jedis outer = outerPool.getResource()) { +//// dbsize = Math.toIntExact(outer.scard("compare")); +//// } +//// if (dbsize != 0){ +// stop = newCoreCompare(job, errorPairs, filenames, outerPool); +//// } +// } +// log.info("Completed worker {}",threadID); +// } +// } public static boolean newCoreCompare( String treeType,ArrayList errorPairs, HashMap filenames,JedisPool outerPool ) { diff --git a/src/main/resource/MF0012.local.app.properties b/src/main/resource/MF0012.local.app.properties new file mode 100644 index 0000000..a12aa3f --- /dev/null +++ b/src/main/resource/MF0012.local.app.properties @@ -0,0 +1,19 @@ + +portDumps = 6399 +numOfWorkers = 14 +hunkLimit = 10 +patchSize = 50 + +projectList = libtiff,php-src,cpython,wireshark,gzip,gmp,lighttpd1.4,lighttpd2 + +#inputPath = /Users/anilkoyuncu/projects/gumInputLinux +#inputPath = /Users/anil.koyuncu/projects/fixminer/fixminer-data/gumInputLinux +inputPath = /Users/anil.koyuncu/projects/test/fixminer-data/patches +#redisPath = /Users/anil.koyuncu/projects/fixminer/fixminer-core/python/data/redis +#redisPath = /Users/anil.koyuncu/projects/fixminer/fixminer-core/python/data/redis +redisPath = /Users/anil.koyuncu/projects/test/fixminer-core/python/data/redis +#srcMLPath= /Users/anil.koyuncu/Downloads/srcML.0.9.5/bin/srcml +srcMLPath= /Users/anil.koyuncu/projects/test/srcML/bin/srcml +#ENHANCEDASTDIFF,CACHE,LEVEL1,LEVEL2,LEVEL3 + +