/** Default constructor */ public ResourcePrinter(OutputStream stream) { writer = new IndentWriter(stream); writer.setIndentString(" "); initLimClassToNameMap(); writer.println("//"); writer.println("// Design Resource Utilization Report"); final String runDate = EngineThread.getGenericJob() .getOption(OptionRegistry.RUN_DATE) .getValue(CodeLabel.UNSCOPED) .toString(); writer.println("// Generated on: " + runDate); writer.println("//\n"); }
/** * Prints dotted line according to the previous line length * * @param previous previous line */ private void printDotted(String previous) { final int length = previous.length(); String dotted_line = "-"; for (int i = 0; i < length - 1; i++) { dotted_line = dotted_line + "-"; } writer.println(dotted_line); }
/** * Prints design resources. * * @param designRes design resources to be printed */ public void print(DesignResource designRes) { /** prints total design resource count */ writer.println(designRes.getDesign().showIDLogical() + " Total: "); printResource(designRes.generateReport()); writer.println(""); // designResource = designRes; String s = "Design: " + designRes.getDesign().showIDLogical(); writer.println(s); printDotted(s); /** now traverse design tasks */ for (Iterator<Object> iter = designRes.getResources().iterator(); iter.hasNext(); ) { print((TaskResource) iter.next()); } }
/** * 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); } }
/** * Prints task resources * * @param taskResource task resources to be printed */ public void print(TaskResource taskResource) { String s = "Entry: " + taskResource.getTask().getCall().showIDLogical(); // writer.inc(); writer.println(s); printDotted(s); /** print entry resources first and any sub method calls */ for (Iterator<Object> iter = taskResource.getResources().iterator(); iter.hasNext(); ) { print((ProcedureResource) iter.next()); upper_method_name = null; } /** prints total task resources */ printDotted(s + " Total:"); writer.println(s + " Total: "); printResource(taskResource.generateReport()); printDotted(s + " Total:"); writer.println(""); // writer.dec(); }
/** * 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(); } } } }