1 22 package org.jboss.varia.stats.report; 23 24 import org.jboss.varia.stats.TxReport; 25 import org.jboss.varia.stats.StatisticalItem; 26 import org.jboss.varia.stats.TxStatistics; 27 28 import java.util.Iterator ; 29 import java.util.Map ; 30 31 35 public class GeneralReportGenerator 36 extends ReportGenerator 37 { 38 public void content(String reportName, StringBuffer buf) throws Exception 39 { 40 buf.append("<table><tr valign='top'><td>"); 41 42 buf.append("<table>"); 43 buf.append("<tr><th>Transaction started by</th><th>total</th>"); 44 buf.append("</tr>"); 45 46 TxStatistics stats = getTxStatistics(); 47 for(Iterator iter = stats.getReports(); iter.hasNext();) 48 { 49 TxReport report = (TxReport) iter.next(); 50 51 String name = report.getName(); 52 buf.append("<tr valign='top'>") 53 .append("<td>"); 54 55 boolean anchor = !name.equals(reportName) && reportName != null; 56 if(anchor) 57 { 58 buf.append("<a HREF='HtmlAdaptor?") 59 .append("action=invokeOpByName&name=") 60 .append(getServiceName()) 61 .append("&methodName=generate&") 62 .append("argType=java.lang.String&arg0=") 63 .append(name) 64 .append("'>"); 65 } 66 67 buf.append(name) 68 .append("</td><td>") 69 .append(report.getCount()) 70 .append("</td>"); 71 72 if(anchor) 73 { 74 buf.append("</a>"); 75 } 76 77 buf.append("</td></tr>"); 78 } 79 80 buf.append("</table>"); 81 buf.append("</td><td>"); 82 83 TxReport report = stats.getReports(reportName); 84 if(report != null) 85 { 86 buf.append("<table><tr>"); 87 88 String [] itemNames = stats.getCollectedItemNames(); 89 for(int i = 0; i < itemNames.length; ++i) 90 { 91 buf.append("<th>").append(itemNames[i]).append("</th>"); 92 } 93 94 buf.append("</tr><tr valign='top'>"); 95 96 for(int i = 0; i < itemNames.length; ++i) 97 { 98 buf.append("<td>"); 99 String itemName = itemNames[i]; 100 101 Map itemMap = (Map ) report.getStats().get(itemName); 102 if(itemMap != null && !itemMap.isEmpty()) 103 { 104 buf.append("<table width='100%'>") 105 .append("<tr><th>item</th><th>%</th><th>avg</th><th>min</th><th>max</th></tr>"); 106 107 for(Iterator itemIter = itemMap.values().iterator(); itemIter.hasNext();) 108 { 109 StatisticalItem item = (StatisticalItem) itemIter.next(); 110 buf.append("<tr><td>") 111 .append(item.getValue()) 112 .append("</td><td>") 113 .append(100*((double)item.getMergedItemsTotal() / report.getCount())) 114 .append("</td><td>") 115 .append(((double) item.getCount()) / report.getCount()) 116 .append("</td><td>") 117 .append(item.getMinCountPerTx()) 118 .append("</td><td>") 119 .append(item.getMaxCountPerTx()) 120 .append("</td>"); 121 } 122 123 buf.append("</table>"); 124 } 125 126 buf.append("</td>"); 127 } 128 129 buf.append("</tr></table>"); 130 } 131 132 buf.append("</td></tr></table>"); 133 134 buf.append("<ul>") 135 .append("<li><b>Transaction started by</b> - the method which started the transaction</li>") 136 .append("<li><b>total</b> - the total number of transactions in the run</li>") 137 .append("<li><b>%</b> - the percentage of transactions this item took place in</li>") 138 .append("<li><b>avg</b> - the average number of times the item took place in the given transaction</li>") 139 .append("<li><b>min</b> - the minimum number of times the item took place in the given transaction</li>") 140 .append("<li><b>max</b> - the maximum number of times the item took place in the given transaction</li>") 141 .append("</ul>"); 142 } 143 } 144 | Popular Tags |