From 0840d6ed4e132218cde89ee8995da61465f2bd86 Mon Sep 17 00:00:00 2001 From: uid1038 Date: Thu, 28 Feb 2013 23:29:28 +0000 Subject: [PATCH] changes for generating evaluation numbers. --- Robust/src/Analysis/SSJava/BuildLattice.java | 14 ++++- .../Analysis/SSJava/LocationInference.java | 61 ++++++++++++++++++- 2 files changed, 71 insertions(+), 4 deletions(-) diff --git a/Robust/src/Analysis/SSJava/BuildLattice.java b/Robust/src/Analysis/SSJava/BuildLattice.java index e24965e3..9db19746 100644 --- a/Robust/src/Analysis/SSJava/BuildLattice.java +++ b/Robust/src/Analysis/SSJava/BuildLattice.java @@ -46,7 +46,8 @@ public class BuildLattice { HierarchyGraph inputGraph = infer.getSkeletonCombinationHierarchyGraph(desc); LocationSummary locSummary = infer.getLocationSummary(desc); - HierarchyGraph naiveGraph = infer.getSimpleHierarchyGraph(desc); + HierarchyGraph simpleGraph = infer.getSimpleHierarchyGraph(desc); + HierarchyGraph naiveGraph = simpleGraph.clone(); // I don't think we need to keep the below if statement anymore // because hierarchy graph does not have any composite location @@ -85,7 +86,16 @@ public class BuildLattice { SSJavaLattice naive_lattice = buildLattice(desc, naiveBasisSet, naiveGraph, null, naive_mapImSucc); - LocationInference.numLocationsNaive += naive_lattice.getKeySet().size(); + int numLocs = naive_lattice.getKeySet().size(); + LocationInference.numLocationsNaive += numLocs; + infer.mapNumLocsMapNaive.put(desc, new Integer(numLocs)); + + int numPaths = naive_lattice.countPaths(); + infer.mapNumPathsMapNaive.put(desc, new Integer(numPaths)); + + System.out.println(desc + " numPaths=" + numPaths + " numLocs=" + + naive_lattice.getKeySet().size()); + infer.addNaiveLattice(desc, naive_lattice); } diff --git a/Robust/src/Analysis/SSJava/LocationInference.java b/Robust/src/Analysis/SSJava/LocationInference.java index e951c1a9..0eff2640 100644 --- a/Robust/src/Analysis/SSJava/LocationInference.java +++ b/Robust/src/Analysis/SSJava/LocationInference.java @@ -187,6 +187,15 @@ public class LocationInference { public static int numLocationsSInfer = 0; public static int numLocationsNaive = 0; + public static int numPathsSInfer = 0; + public static int numPathsNaive = 0; + + public Map mapNumPathsMapSInfer; + public Map mapNumLocsMapSInfer; + + public Map mapNumPathsMapNaive; + public Map mapNumLocsMapNaive; + public LocationInference(SSJavaAnalysis ssjava, State state, TypeUtil tu) { this.ssjava = ssjava; this.state = state; @@ -256,6 +265,12 @@ public class LocationInference { mapHighestOverriddenMethodDescToSetHigherThanRETURNLoc = new HashMap>>(); + mapNumPathsMapSInfer = new HashMap(); + mapNumLocsMapSInfer = new HashMap(); + + mapNumPathsMapNaive = new HashMap(); + mapNumLocsMapNaive = new HashMap(); + this.buildLattice = new BuildLattice(this); } @@ -371,6 +386,8 @@ public class LocationInference { } System.out.println("The number of elements: SInfer=" + numLocationsSInfer); + writeNumLocsPathsCSVFile(); + System.exit(0); } @@ -2633,8 +2650,15 @@ public class LocationInference { } lattice.removeRedundantEdges(); - LocationInference.numLocationsSInfer += lattice.getKeySet().size(); - System.out.println(desc + " numPaths=" + lattice.countPaths()); + int numLocs = lattice.getKeySet().size(); + LocationInference.numLocationsSInfer += numLocs; + mapNumLocsMapSInfer.put(desc, new Integer(numLocs)); + + int numPaths = lattice.countPaths(); + LocationInference.numLocationsSInfer += numPaths; + mapNumPathsMapSInfer.put(desc, new Integer(numPaths)); + + System.out.println(desc + " numPaths=" + numPaths + " numLocs=" + numLocs); if (desc instanceof ClassDescriptor) { // field lattice @@ -6622,6 +6646,39 @@ public class LocationInference { writeInferredLatticeDotFile(cd, null, locOrder, nameSuffix); } + public void writeNumLocsPathsCSVFile() { + + try { + BufferedWriter bw = new BufferedWriter(new FileWriter("sinfernumbers.csv")); + + Set keySet = mapNumLocsMapSInfer.keySet(); + for (Iterator iterator = keySet.iterator(); iterator.hasNext();) { + Descriptor desc = (Descriptor) iterator.next(); + int numLocs = mapNumLocsMapSInfer.get(desc); + int numPaths = mapNumPathsMapSInfer.get(desc); + bw.write(desc.getSymbol().replaceAll("[,]", "") + "," + numLocs + "," + numPaths + "\n"); + } + bw.close(); + + if (state.SSJAVA_INFER_NAIVE_WRITEDOTS) { + BufferedWriter bw2 = new BufferedWriter(new FileWriter("naivenumbers.csv")); + Set keySet2 = mapNumLocsMapNaive.keySet(); + for (Iterator iterator = keySet2.iterator(); iterator.hasNext();) { + Descriptor desc = (Descriptor) iterator.next(); + int numLocs = mapNumLocsMapNaive.get(desc); + int numPaths = mapNumPathsMapNaive.get(desc); + bw2.write(desc.getSymbol().replaceAll("[,]", "") + "," + numLocs + "," + numPaths + "\n"); + } + bw2.close(); + } + + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + public void writeInferredLatticeDotFile(ClassDescriptor cd, MethodDescriptor md, SSJavaLattice locOrder, String nameSuffix) { -- 2.34.1