changes for generating evaluation numbers.
authoruid1038 <uid1038>
Thu, 28 Feb 2013 23:29:28 +0000 (23:29 +0000)
committeruid1038 <uid1038>
Thu, 28 Feb 2013 23:29:28 +0000 (23:29 +0000)
Robust/src/Analysis/SSJava/BuildLattice.java
Robust/src/Analysis/SSJava/LocationInference.java

index e24965e35b5916b223b07eb0083d555bfbbcabd0..9db197469bc40e6b89f7593d7dd10e11b3b637da 100644 (file)
@@ -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<String> 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);
     }
 
index e951c1a970e7b0214c2f7649184dbc0207d76d2a..0eff2640182cf9653126302437a1bb1939205e1b 100644 (file)
@@ -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<Descriptor, Integer> mapNumPathsMapSInfer;
+  public Map<Descriptor, Integer> mapNumLocsMapSInfer;
+
+  public Map<Descriptor, Integer> mapNumPathsMapNaive;
+  public Map<Descriptor, Integer> 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<MethodDescriptor, Set<NTuple<Descriptor>>>();
 
+    mapNumPathsMapSInfer = new HashMap<Descriptor, Integer>();
+    mapNumLocsMapSInfer = new HashMap<Descriptor, Integer>();
+
+    mapNumPathsMapNaive = new HashMap<Descriptor, Integer>();
+    mapNumLocsMapNaive = new HashMap<Descriptor, Integer>();
+
     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<Descriptor> 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<Descriptor> 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<String> locOrder, String nameSuffix) {