Ejemplo n.º 1
0
    public static void printViewPatterns() {
      processedViewsForPatterns = new HashSet<ViewTrace>();
      HashMap<String, Integer> viewPatterns = new HashMap<String, Integer>();

      ps.println("ViewPatterns ------------------- \n");
      for (ViewTrace trace : viewsRegistry) {
        if (processedViewsForPatterns.contains(trace)) {
          continue;
        }
        ViewTrace v = trace.getRootView();
        StringBuilder p = new StringBuilder();
        p.append("PATTERN ");
        extractViewPattern(0, v, p);
        p.append("\n");
        String pattern = p.toString();
        Integer count = viewPatterns.get(pattern);
        if (count == null) {
          viewPatterns.put(pattern, 1);
        } else {
          viewPatterns.put(pattern, count + 1);
        }
      }
      processedViewsForPatterns = null;
      for (Map.Entry<String, Integer> e : viewPatterns.entrySet()) {
        ps.print("(" + e.getValue() + ") ");
        ps.println(e.getKey());
      }
    }
Ejemplo n.º 2
0
    public static void printSite(Site s, StringBuilder out) {
      if (s == null) {
        out.append("(null)");
        return;
      }
      StackTraceElement[] st = s.site();

      int interestingSitesPrinted = 0;
      for (int i = s.offset; i < st.length; i++) {
        StackTraceElement e = st[i];
        String fileName = e.getFileName();
        if (THIS_FILE_NAME.equals(fileName)) {
          continue;
        }
        out.append(" " + e.getMethodName() + "(" + e.getFileName() + ":" + e.getLineNumber() + ")");
        interestingSitesPrinted++;
        if (interestingSitesPrinted <= SITES_TO_PRINT) {
          continue;
        }
        if (fileName == null || "View.java".equals(fileName)) {
          continue;
        }
        String methodName = e.getMethodName();
        if (skipMethods.contains(methodName)) {
          continue;
        }
        break;
      }
    }
Ejemplo n.º 3
0
 public ViewTrace(RArray real) {
   getCounts = new int[real.size()];
   allocationSite = TRACE_ALLOCATION_SITE ? new Site() : null;
   useSites = new HashSet<Site>();
   realView = real;
   viewsRegistry.add(this);
   linkChildren(real, this);
 }
Ejemplo n.º 4
0
 public static void printIndividualViews() {
   printedIndividualViews = new HashSet<ViewTrace>();
   ps.println("Individual views statistics ------------------- \n");
   for (ViewTrace trace : viewsRegistry) {
     if (printedIndividualViews.contains(trace)) {
       continue;
     }
     ViewTrace v = trace.getRootView();
     ps.print("ROOT ");
     dumpView(0, v);
     ps.println();
   }
   printViewPatterns();
   printedIndividualViews = null;
 }
Ejemplo n.º 5
0
 private Site updateUseSite() {
   if (TRACE_USE_SITES) {
     Site here = new Site();
     useSites.add(here);
     return here;
   } else if (TRACE_SINGLE_USE_SITE) {
     if (multipleUseSites) {
       return null;
     } else {
       Site here = new Site();
       if (singleUseSite == null) {
         singleUseSite = here;
       } else {
         if (!here.equals(singleUseSite)) {
           multipleUseSites = true;
           singleUseSite = null;
         }
       }
       return here;
     }
   } else {
     return null;
   }
 }