new compare visualization

This commit is contained in:
mimic
2020-03-06 15:17:26 +01:00
parent c8b916bbe8
commit a00b2a9b61
2 changed files with 92 additions and 55 deletions
@@ -1,5 +1,6 @@
package edu.lu.uni.serval.fixminer.jobs; 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.CallShell;
import edu.lu.uni.serval.utils.EDiffHelper; import edu.lu.uni.serval.utils.EDiffHelper;
import edu.lu.uni.serval.utils.PoolBuilder; 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.Executors;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.IntStream;
/** /**
@@ -57,38 +59,54 @@ public class CompareTrees {
// List<String> listOfPairs = AkkaTreeParser.files2compare(outerPool); // List<String> listOfPairs = AkkaTreeParser.files2compare(outerPool);
ArrayList<String> samePairs = new ArrayList<>(); // ArrayList<String> samePairs = new ArrayList<>();
ArrayList<String> errorPairs = new ArrayList<>(); ArrayList<String> errorPairs = new ArrayList<>();
Integer numberOfWorkers = Integer.valueOf(numOfWorkers); // Integer numberOfWorkers = Integer.valueOf(numOfWorkers);
final ExecutorService executor = Executors.newWorkStealingPool(numberOfWorkers); // final ExecutorService executor = Executors.newWorkStealingPool(numberOfWorkers);
ArrayList<Future<?>> results = new ArrayList<Future<?>>(); Long compare;
for (int i = 1; i <numberOfWorkers ; i++) { try (Jedis inner = outerPool.getResource()) {
compare = inner.scard("compare");
// schedule the work
log.info("Starting job {}",i);
final Future<?> future = executor.submit(new RunnableCompare(job, errorPairs, filenames, outerPool, i));
results.add(future);
} }
for (Future<?> future : ProgressBar.wrap(results, "Comparing")){ IntStream stream = IntStream.range(0, compare.intValue());
// for (Future<?> future:results){
try {
// wait for task to complete
future.get();
} catch (InterruptedException e) { ProgressBar.wrap(stream.
parallel(),"Task").
e.printStackTrace(); forEach(m ->
} catch (ExecutionException e) { {
newCoreCompare(job, errorPairs, filenames, outerPool);
}
);
e.printStackTrace(); //
} // ArrayList<Future<?>> results = new ArrayList<Future<?>>();
// finally { // for (int i = 0; i <numberOfWorkers ; i++) {
// executor.shutdownNow(); //
//
// // schedule the work
// log.info("Starting job {}",i);
// final Future<?> 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();
// } // }
} //// finally {
executor.shutdownNow(); //// executor.shutdownNow();
//// }
// }
// executor.shutdownNow();
@@ -97,36 +115,36 @@ public class CompareTrees {
} }
public static class RunnableCompare implements Runnable { // public static class RunnableCompare implements Runnable {
String job; // String job;
ArrayList<String> errorPairs; // ArrayList<String> errorPairs;
HashMap<String, String> filenames; // HashMap<String, String> filenames;
JedisPool outerPool; // JedisPool outerPool;
Integer threadID; // Integer threadID;
//
public RunnableCompare(String treeType,ArrayList<String> errorPairs, HashMap<String, String> filenames,JedisPool outerPool,Integer threadID) { // public RunnableCompare(String treeType,ArrayList<String> errorPairs, HashMap<String, String> filenames,JedisPool outerPool,Integer threadID) {
this.job = treeType; // this.job = treeType;
this.errorPairs = errorPairs; // this.errorPairs = errorPairs;
this.filenames = filenames; // this.filenames = filenames;
this.outerPool = outerPool; // this.outerPool = outerPool;
this.threadID = threadID; // this.threadID = threadID;
} // }
//
@Override // @Override
public void run() { // public void run() {
// int dbsize = 1; //// int dbsize = 1;
boolean stop = true; // boolean stop = true;
while(stop) { // while(stop) {
// try (Jedis outer = outerPool.getResource()) { //// try (Jedis outer = outerPool.getResource()) {
// dbsize = Math.toIntExact(outer.scard("compare")); //// dbsize = Math.toIntExact(outer.scard("compare"));
// } //// }
// if (dbsize != 0){ //// if (dbsize != 0){
stop = newCoreCompare(job, errorPairs, filenames, outerPool); // stop = newCoreCompare(job, errorPairs, filenames, outerPool);
// } //// }
} // }
log.info("Completed worker {}",threadID); // log.info("Completed worker {}",threadID);
} // }
} // }
public static boolean newCoreCompare( String treeType,ArrayList<String> errorPairs, HashMap<String, String> filenames,JedisPool outerPool ) { public static boolean newCoreCompare( String treeType,ArrayList<String> errorPairs, HashMap<String, String> filenames,JedisPool outerPool ) {
@@ -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