Exemplo n.º 1
0
  /**
   * Prints resources within a procedure recursively which maintains method call hierarchy.
   *
   * @param procResource Procedure report to be printed
   */
  public void print(ProcedureResource procResource) {
    /*
     * tries to imitate java hierarchical name. (ie: main calls test1 and
     * test1 calls test2 will result in "main.test1.test2".
     */
    String s = "";
    if (upper_method_name == null) {
      upper_method_name = procResource.getProcedure().showIDLogical();
      s = "Method: " + upper_method_name;
    } else {
      upper_method_name = upper_method_name + "." + procResource.getProcedure().showIDLogical();
      s = "Method: " + upper_method_name;
    }

    writer.inc();
    writer.println(s);
    printDotted(s);

    /** prints resources local to this method */
    printResource(procResource.generateReport());

    /** prints sub methods before totaling */
    for (Iterator<Object> iter = procResource.getResources().iterator(); iter.hasNext(); ) {
      Object o = iter.next();
      if (o instanceof ProcedureResource) {
        print((ProcedureResource) o);
      }
    }

    /** print total resource count of this method, includes sub methods */
    writer.println();
    writer.println("Method Total:");
    printResource(procResource.getTotalReport());
    printDotted("Method Total:");
    writer.dec();

    /** removes last method (which is current method) name before existing */
    int last = upper_method_name.lastIndexOf(".");
    if (last >= 0) {
      upper_method_name = upper_method_name.substring(0, last);
    }
  }
Exemplo n.º 2
0
  /**
   * Print each resources with appropriate count. ie: "2 Adds" or "1 Subtract"
   *
   * @param resources resources report
   */
  private void printResource(Map resources) {
    for (Iterator iter = resources.keySet().iterator(); iter.hasNext(); ) {
      final Class<?> key = (Class<?>) iter.next();
      final Set set = (Set) resources.get(key);
      if (getLimClassName(key) == null) {
      } // must be something we arent interested in reporting
      else {
        writer.print(set.size());
        if (set.size() < 10) writer.print("    ");
        else if (set.size() < 100) writer.print("   ");
        else if (set.size() < 1000) writer.print("  ");
        else writer.print(" ");
        writer.print(getLimClassName(key));
        final Map<Integer, Set<?>> sortedByBitWidth = BitWidthFinder.sortByBitWidth(set);
        String values = "";
        for (Integer width : sortedByBitWidth.keySet()) {
          values += sortedByBitWidth.get(width).size() + "x" + width + " ";
        }
        // writer.println(set.size() > 1 ? "s":"");
        // writer.println("       " + values);
        writer.println((set.size() > 1 ? "s" : "") + " : " + values);

        if (EngineThread.getGenericJob()
            .getUnscopedBooleanOptionValue(OptionRegistry.XDETAILED_REPORT)) {
          writer.inc();
          for (Integer width : sortedByBitWidth.keySet()) {
            Set<?> comps = sortedByBitWidth.get(width);
            for (Object obj : comps) {
              if (obj instanceof Component) writer.println(showComponent((Component) obj));
              else writer.println("???");
            }
          }
          writer.dec();
        }
      }
    }
  }