package jeiel.experiment; import java.io.File; import java.io.IOException; import Sequenic.T2.TrFile; import Sequenic.T2.Seq.Trace; import Sequenic.T2ext.Instrumenter.CFGBunchFile; import Sequenic.T2ext.Selection.RegressionTestSelector; import Sequenic.T2ext.Selection.SelectiveRunner; /** * Run in directory of mutated version, e.g. m1/7/. * It expects the original cfgs and trace files to be in ../../originalNtraces * * @author jeiels * */ public final class RunModifiedVersion { // How many traces are selected? (Use BP) // * How long to replay selected // * How long to replay all (necessary?) // * How many are obsolete static void experiment1() { final RegressionTestSelector bp = new RegressionTestSelector( CFGBunchFile.load("../../originalNtraces/java_1_4/util/MyArrayList.cfgs").cfgs, CFGBunchFile.load("./java_1_4/util/MyArrayList.cfgs").cfgs, RegressionTestSelector.BallPartial); try { final String dir = "../../originalNtraces/ex1/"; String m_id = new File("..").getCanonicalFile().getName() + ", " + new File(".").getCanonicalFile().getName() + ", "; String[] list = new File(dir).list(); for(String file : list) { if(!file.startsWith("cov")) continue; String[] _s = file.substring(5).split("_"); System.out.print(m_id+_s[0]+", "+_s[1]+", "); long beginTime = System.currentTimeMillis(); TrFile trFile = TrFile.load(dir+file); SelectiveRunner selRunner = new SelectiveRunner(trFile); beginTime = System.currentTimeMillis() - beginTime; System.out.print(beginTime + ", "); beginTime = System.currentTimeMillis(); int selected = selRunner.runSelected(bp); beginTime = System.currentTimeMillis() - beginTime; System.out.print(beginTime + ", "); int obsolete = 0; for(Trace t : trFile.traces) { if(t.isObsolete()) obsolete++; } System.out.println(selected +", " + obsolete); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); System.exit(1); } } static void makeSel() { long beginTime = System.currentTimeMillis(); CFGBunchFile oldCFGs = CFGBunchFile.load("../../originalNtraces/java_1_4/util/MyArrayList.cfgs"); long load1 = System.currentTimeMillis(); CFGBunchFile newCFGs = CFGBunchFile.load("./java_1_4/util/MyArrayList.cfgs"); long load2 = System.currentTimeMillis(); final RegressionTestSelector bp = new RegressionTestSelector( oldCFGs.cfgs, newCFGs.cfgs, RegressionTestSelector.RothermelHarrold); long makeSel = System.currentTimeMillis(); try { String m_id = new File("..").getCanonicalFile().getName() + ", " + new File(".").getCanonicalFile().getName(); System.out.print(m_id); System.out.format(", %d, %d, %d, %d %n",(load1-beginTime),(load2-load1),(makeSel-load2),(makeSel-beginTime)); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } public static void main(String[] args) { experiment1(); } }