1 18 package org.apache.activemq.tool.reports; 19 20 import org.apache.activemq.tool.reports.plugins.ThroughputReportPlugin; 21 import org.apache.activemq.tool.reports.plugins.CpuReportPlugin; 22 23 import java.util.Properties ; 24 import java.util.Iterator ; 25 import java.util.Map ; 26 import java.util.Arrays ; 27 28 public class VerbosePerfReportWriter extends AbstractPerfReportWriter { 29 30 public void openReportWriter() { 31 } 33 34 public void closeReportWriter() { 35 writeHeader("Performance Summary"); 36 writePerfSummary(); 37 } 38 39 public void writeInfo(String info) { 40 System.out.println("[PERF-INFO]: " + info); 41 } 42 43 public void writeCsvData(int csvType, String csvData) { 44 if (csvType == REPORT_PLUGIN_THROUGHPUT) { 45 System.out.println("[PERF-TP]: " + csvData); 46 } else if (csvType == REPORT_PLUGIN_CPU) { 47 System.out.println("[PERF-CPU]: " + csvData); 48 } 49 handleCsvData(csvType, csvData); 50 } 51 52 public void writeProperties(String header, Properties props) { 53 writeHeader(header); 54 writeProperties(props); 55 } 56 57 public void writeProperties(Properties props) { 58 for (Iterator i=props.keySet().iterator(); i.hasNext();) { 59 String key = (String )i.next(); 60 String val = props.getProperty(key, ""); 61 System.out.println("[PERF-PROP]: " + key + "=" + val); 62 } 63 } 64 65 public void writePerfSummary() { 66 67 Map summary; 68 69 summary = getSummary(REPORT_PLUGIN_THROUGHPUT); 70 if (summary != null && summary.size() > 0) { 71 writeThroughputSummary(summary); 72 } 73 74 summary = getSummary(REPORT_PLUGIN_CPU); 75 if (summary != null && summary.size() > 0) { 76 writeCpuSummary(summary); 77 } 78 79 } 80 81 protected void writeThroughputSummary(Map summary) { 82 writeHeader("SYSTEM THROUGHPUT SUMMARY"); 83 System.out.println("[PERF-TP-SUMMARY] System Total Throughput: " + summary.get(ThroughputReportPlugin.KEY_SYS_TOTAL_TP)); 84 System.out.println("[PERF-TP-SUMMARY] System Total Clients: " + summary.get(ThroughputReportPlugin.KEY_SYS_TOTAL_CLIENTS)); 85 System.out.println("[PERF-TP-SUMMARY] System Average Throughput: " + summary.get(ThroughputReportPlugin.KEY_SYS_AVE_TP)); 86 System.out.println("[PERF-TP-SUMMARY] System Average Throughput Excluding Min/Max: " + summary.get(ThroughputReportPlugin.KEY_SYS_AVE_EMM_TP)); 87 System.out.println("[PERF-TP-SUMMARY] System Average Client Throughput: " + summary.get(ThroughputReportPlugin.KEY_SYS_AVE_CLIENT_TP)); 88 System.out.println("[PERF-TP-SUMMARY] System Average Client Throughput Excluding Min/Max: " + summary.get(ThroughputReportPlugin.KEY_SYS_AVE_CLIENT_EMM_TP)); 89 System.out.println("[PERF-TP-SUMMARY] Min Client Throughput Per Sample: " + summary.get(ThroughputReportPlugin.KEY_MIN_CLIENT_TP)); 90 System.out.println("[PERF-TP-SUMMARY] Max Client Throughput Per Sample: " + summary.get(ThroughputReportPlugin.KEY_MAX_CLIENT_TP)); 91 System.out.println("[PERF-TP-SUMMARY] Min Client Total Throughput: " + summary.get(ThroughputReportPlugin.KEY_MIN_CLIENT_TOTAL_TP)); 92 System.out.println("[PERF-TP-SUMMARY] Max Client Total Throughput: " + summary.get(ThroughputReportPlugin.KEY_MAX_CLIENT_TOTAL_TP)); 93 System.out.println("[PERF-TP-SUMMARY] Min Client Average Throughput: " + summary.get(ThroughputReportPlugin.KEY_MIN_CLIENT_AVE_TP)); 94 System.out.println("[PERF-TP-SUMMARY] Max Client Average Throughput: " + summary.get(ThroughputReportPlugin.KEY_MAX_CLIENT_AVE_TP)); 95 System.out.println("[PERF-TP-SUMMARY] Min Client Average Throughput Excluding Min/Max: " + summary.get(ThroughputReportPlugin.KEY_MIN_CLIENT_AVE_EMM_TP)); 96 System.out.println("[PERF-TP-SUMMARY] Max Client Average Throughput Excluding Min/Max: " + summary.get(ThroughputReportPlugin.KEY_MAX_CLIENT_AVE_EMM_TP)); 97 } 98 99 protected void writeCpuSummary(Map summary) { 100 writeHeader("SYSTEM CPU USAGE SUMMARY"); 101 System.out.println("[PERF-CPU-SUMMARY] Total Blocks Received: " + summary.get(CpuReportPlugin.KEY_BLOCK_RECV)); 102 System.out.println("[PERF-CPU-SUMMARY] Ave Blocks Received: " + summary.get(CpuReportPlugin.KEY_AVE_BLOCK_RECV)); 103 104 System.out.println("[PERF-CPU-SUMMARY] Total Blocks Sent: " + summary.get(CpuReportPlugin.KEY_BLOCK_SENT)); 105 System.out.println("[PERF-CPU-SUMMARY] Ave Blocks Sent: " + summary.get(CpuReportPlugin.KEY_AVE_BLOCK_SENT)); 106 107 System.out.println("[PERF-CPU-SUMMARY] Total Context Switches: " + summary.get(CpuReportPlugin.KEY_CTX_SWITCH)); 108 System.out.println("[PERF-CPU-SUMMARY] Ave Context Switches: " + summary.get(CpuReportPlugin.KEY_AVE_CTX_SWITCH)); 109 110 System.out.println("[PERF-CPU-SUMMARY] Total User Time: " + summary.get(CpuReportPlugin.KEY_USER_TIME)); 111 System.out.println("[PERF-CPU-SUMMARY] Ave User Time: " + summary.get(CpuReportPlugin.KEY_AVE_USER_TIME)); 112 113 System.out.println("[PERF-CPU-SUMMARY] Total System Time: " + summary.get(CpuReportPlugin.KEY_SYS_TIME)); 114 System.out.println("[PERF-CPU-SUMMARY] Ave System Time: " + summary.get(CpuReportPlugin.KEY_AVE_SYS_TIME)); 115 116 System.out.println("[PERF-CPU-SUMMARY] Total Idle Time: " + summary.get(CpuReportPlugin.KEY_IDLE_TIME)); 117 System.out.println("[PERF-CPU-SUMMARY] Ave Idle Time: " + summary.get(CpuReportPlugin.KEY_AVE_IDLE_TIME)); 118 119 System.out.println("[PERF-CPU-SUMMARY] Total Wait Time: " + summary.get(CpuReportPlugin.KEY_WAIT_TIME)); 120 System.out.println("[PERF-CPU-SUMMARY] Ave Wait Time: " + summary.get(CpuReportPlugin.KEY_AVE_WAIT_TIME)); 121 } 122 123 protected void writeHeader(String header) { 124 char[] border = new char[header.length() + 8]; Arrays.fill(border, '#'); 126 String borderStr = new String (border); 127 128 System.out.println(borderStr); 129 System.out.println("# " + header + " #"); 130 System.out.println(borderStr); 131 } 132 133 } 134 | Popular Tags |