[jboss-cvs] JBoss Profiler SVN: r453 - branches/JBossProfiler2/src/main/org/jboss/profiler/client.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon May 19 16:15:51 EDT 2008
Author: jesper.pedersen
Date: 2008-05-19 16:15:51 -0400 (Mon, 19 May 2008)
New Revision: 453
Modified:
branches/JBossProfiler2/src/main/org/jboss/profiler/client/SnapshotUtil.java
Log:
Added package report
Modified: branches/JBossProfiler2/src/main/org/jboss/profiler/client/SnapshotUtil.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/client/SnapshotUtil.java 2008-05-18 17:10:26 UTC (rev 452)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/client/SnapshotUtil.java 2008-05-19 20:15:51 UTC (rev 453)
@@ -203,6 +203,7 @@
dumpOverview(snapshot, info, classes, directory);
dumpMethods(info, directory);
dumpHotspots(info, directory);
+ dumpPackages(info, directory);
dumpClasses(classes, info, snapshot.getAllocations(), directory);
}
}
@@ -675,4 +676,71 @@
bw.flush();
bw.close();
}
+
+ /**
+ * Dump the packages to a file writer
+ * @param info The combined frame information
+ * @param directory The directory
+ * @exception Exception If an error occurs
+ */
+ protected void dumpPackages(Map<String, List<CombinedFrameInfo>> info,
+ String directory) throws Exception {
+ FileWriter fw = new FileWriter(directory + "packages.txt");
+ BufferedWriter bw = new BufferedWriter(fw, 8192);
+
+ DecimalFormat df = new DecimalFormat("#0.00");
+
+ bw.write("Packages:" + NEW_LINE);
+ bw.write("=========" + NEW_LINE);
+ bw.write("%\tMs\tPackage" + NEW_LINE);
+
+ Map<String, CombinedFrameInfo> packages = new HashMap<String, CombinedFrameInfo>();
+
+ Iterator it = info.entrySet().iterator();
+ while (it.hasNext()) {
+ Map.Entry entry = (Map.Entry)it.next();
+ String key = (String)entry.getKey();
+ List<CombinedFrameInfo> value = (List<CombinedFrameInfo>)entry.getValue();
+
+ for (CombinedFrameInfo cfi : value) {
+ String cn = cfi.getClassName();
+ cn = cn.replace('/', '.');
+ if (cn.lastIndexOf(".") != -1) {
+ cn = cn.substring(0, cn.lastIndexOf("."));
+ }
+
+ CombinedFrameInfo ci = packages.get(cn);
+ if (ci == null) {
+ ci = new CombinedFrameInfo(cn, cn);
+ }
+ ci.increaseTotalTime(cfi.getTotalTime());
+ ci.increasePercent(cfi.getPercent());
+ packages.put(cn, ci);
+ }
+ }
+
+ List<CombinedFrameInfo> result = new ArrayList<CombinedFrameInfo>(packages.values());
+ Collections.sort(result, new CombinedFrameComparator(CombinedFrameComparator.TOTAL_TIME));
+
+ int count = 0;
+
+ for (CombinedFrameInfo cfi: result) {
+ if (cfi.getTotalTime() > threshold) {
+ bw.write(df.format(cfi.getPercent()) + "\t");
+ bw.write(df.format(cfi.getTotalTime()) + "\t");
+ bw.write(cfi.getClassName());
+ bw.write(NEW_LINE);
+ } else {
+ count++;
+ }
+ }
+
+ if (count > 0) {
+ bw.write(NEW_LINE);
+ bw.write(count + " packages below threshold." + NEW_LINE);
+ }
+
+ bw.flush();
+ bw.close();
+ }
}
More information about the jboss-cvs-commits
mailing list