1 16 package org.apache.cocoon.components.profiler; 17 18 19 20 29 public class ProfilerResult { 30 31 private String uri; 33 34 private String [] roles; 36 37 private String [] sources; 39 40 private int count = 0; 42 43 private EnvironmentInfo[] latestEnvironmentInfo; 45 46 private long[] totalTime; 48 49 private long[][] latestSetupTimes; 51 52 private long[][] latestProcessingTimes; 54 55 private Object [][] latestFragments; 57 58 public ProfilerResult(String uri, int latestResultsCount) { 59 this.uri = uri; 60 this.latestEnvironmentInfo = new EnvironmentInfo[(latestResultsCount>0)?latestResultsCount:5]; 61 this.latestSetupTimes = new long[(latestResultsCount>0)?latestResultsCount:5][]; 62 this.latestProcessingTimes = new long[(latestResultsCount>0)?latestResultsCount:5][]; 63 this.totalTime = new long[(latestResultsCount>0)?latestResultsCount:5]; 64 this.latestFragments = new Object [(latestResultsCount>0)?latestResultsCount:5][]; 65 this.count = 0; 66 } 67 68 71 public void addData(ProfilerData data) { 72 ProfilerData.Entry[] entries = data.getEntries(); 73 synchronized(this){ 74 if(roles == null || roles.length != entries.length){ 75 roles = new String [entries.length]; 77 sources = new String [entries.length]; 78 for(int i=0; i<entries.length; i++){ 79 roles[i] = entries[i].role; 80 sources[i] = entries[i].source; 81 } 82 83 this.count = 0; 85 } 86 87 if (latestProcessingTimes != null) { 88 for (int i = latestProcessingTimes.length - 1; i > 0; i--) { 90 latestEnvironmentInfo[i] = latestEnvironmentInfo[i - 1]; 91 totalTime[i] = totalTime[i - 1]; 92 latestSetupTimes[i] = latestSetupTimes[i - 1]; 93 latestProcessingTimes[i] = latestProcessingTimes[i - 1]; 94 latestFragments[i] = latestFragments[i - 1]; 95 } 96 latestEnvironmentInfo[0] = data.getEnvironmentInfo(); 97 totalTime[0] = data.getTotalTime(); 98 99 latestSetupTimes[0] = new long[entries.length]; 100 for(int i=0; i<entries.length; i++) 101 this.latestSetupTimes[0][i] = entries[i].setup; 102 103 latestProcessingTimes[0] = new long[entries.length]; 104 for(int i=0; i<entries.length; i++) 105 this.latestProcessingTimes[0][i] = entries[i].time; 106 107 latestFragments[0] = new Object [entries.length]; 108 for(int i=0; i<entries.length; i++) 109 latestFragments[0][i] = entries[i].fragment; 110 111 if (count<latestProcessingTimes.length) 112 count++; 113 } 114 } 115 } 116 117 120 public String getURI() { 121 return uri; 122 } 123 124 127 public String [] getRoles() { 128 return roles; 129 } 130 131 134 public String [] getSources() { 135 return sources; 136 } 137 138 141 public int getCount() { 142 return count; 143 } 144 145 148 public EnvironmentInfo[] getLatestEnvironmentInfos() { 149 return latestEnvironmentInfo; 150 } 151 152 155 public long[] getTotalTime() { 156 return totalTime; 157 } 158 159 162 public long[][] getSetupTimes() { 163 return latestSetupTimes; 164 } 165 166 169 public long[][] getProcessingTimes() { 170 return latestProcessingTimes; 171 } 172 173 176 public Object [][] getSAXFragments() { 177 return latestFragments; 178 } 179 } 180 | Popular Tags |