[104] | 1 | package simulator.stats; |
---|
| 2 | |
---|
| 3 | import static simulator.stats.SimulationStatisticsOld.FAILED_REQUESTS; |
---|
| 4 | import static simulator.stats.SimulationStatisticsOld.TASK_TARDINESS; |
---|
| 5 | import static simulator.stats.SimulationStatisticsOld.DELAYED_TASKS; |
---|
| 6 | import static simulator.stats.SimulationStatisticsOld.TASK_LATENESS; |
---|
| 7 | import static simulator.stats.SimulationStatisticsOld.TASK_COMPLETION_TIME; |
---|
| 8 | import static simulator.stats.SimulationStatisticsOld.TASK_FLOW_TIME; |
---|
| 9 | import static simulator.stats.SimulationStatisticsOld.TASK_EXECUTION_TIME; |
---|
| 10 | import static simulator.stats.SimulationStatisticsOld.TASK_WAITING_TIME; |
---|
| 11 | import static simulator.stats.SimulationStatisticsOld.MAKESPAN; |
---|
| 12 | import static simulator.stats.SimulationStatisticsOld.RESOURCES_QUEUE_LENGTH; |
---|
| 13 | import static simulator.stats.SimulationStatisticsOld.RESOURCES_TOTAL_LOAD; |
---|
| 14 | import static simulator.stats.SimulationStatisticsOld.RESOURCES_RESERVATION_LOAD; |
---|
| 15 | |
---|
| 16 | import java.io.File; |
---|
| 17 | import java.io.FileOutputStream; |
---|
| 18 | import java.io.IOException; |
---|
| 19 | import java.io.PrintStream; |
---|
| 20 | import java.util.ArrayList; |
---|
| 21 | import java.util.List; |
---|
| 22 | |
---|
| 23 | import simulator.stats.implementation.GSSimStatistics; |
---|
| 24 | import gridsim.Accumulator; |
---|
| 25 | |
---|
| 26 | |
---|
| 27 | public class AccumulatedStatistics { |
---|
| 28 | |
---|
| 29 | protected static final String ACCUMULATED_SIMULATIONS_STATISTICS_OUTPUT_FILE_NAME = "Stats_Accumulated_Simulations.txt"; |
---|
| 30 | |
---|
| 31 | protected List<SimulationStatistics> simulations; |
---|
| 32 | |
---|
| 33 | public AccumulatedStatistics(int noOfSimulations) { |
---|
| 34 | simulations = new ArrayList<SimulationStatistics>(noOfSimulations); |
---|
| 35 | } |
---|
| 36 | |
---|
| 37 | public AccumulatedStatistics() { |
---|
| 38 | simulations = new ArrayList<SimulationStatistics>(); |
---|
| 39 | } |
---|
| 40 | |
---|
| 41 | public void add(SimulationStatistics simulationStatistics) { |
---|
| 42 | simulations.add(simulationStatistics); |
---|
| 43 | } |
---|
| 44 | |
---|
| 45 | public void saveStatistics() { |
---|
| 46 | |
---|
| 47 | SimulationStatistics simulationStatisticsNew = simulations.get(0); |
---|
| 48 | |
---|
| 49 | if(!simulationStatisticsNew.accumulatedStats()) |
---|
| 50 | return; |
---|
| 51 | String dirName = simulationStatisticsNew.getOutputFolderName(); |
---|
| 52 | if(dirName == null) |
---|
| 53 | return; |
---|
| 54 | |
---|
| 55 | PrintStream out = null; |
---|
| 56 | try { |
---|
| 57 | File file = new File(dirName + ACCUMULATED_SIMULATIONS_STATISTICS_OUTPUT_FILE_NAME); |
---|
| 58 | out = new PrintStream(new FileOutputStream(file)); |
---|
| 59 | } catch (IOException e) { |
---|
| 60 | e.printStackTrace(); |
---|
| 61 | } |
---|
| 62 | |
---|
| 63 | GSSAccumulator resourceLoad = getAccumulatedResourceLoad(); |
---|
| 64 | GSSAccumulator reservationLoad = getAccumulatedReservationLoad(); |
---|
| 65 | GSSAccumulator makespan = getAccumulatedMakespan(); |
---|
| 66 | GSSAccumulator taskExecutionTime = getAccumulatedJobExecutionTime(); |
---|
| 67 | GSSAccumulator taskQueueLength = getAccumulatedQueueJobCount(); |
---|
| 68 | GSSAccumulator taskCompletionTime = getAccumulatedCompletionTime(); |
---|
| 69 | GSSAccumulator taskWaitingTime = getAccumulatedWaitingTime(); |
---|
| 70 | GSSAccumulator taskFlowTime = getAccumulatedJobFlowTime(); |
---|
| 71 | GSSAccumulator taskLateness = getAccumulatedLateness(); |
---|
| 72 | GSSAccumulator delayedTasks = getAccumulatedDelayedTasks(); |
---|
| 73 | GSSAccumulator taskTardiness = getAccumulatedTardiness(); |
---|
| 74 | GSSAccumulator failedRequests = getAccumulatedFailedRequests(); |
---|
| 75 | |
---|
| 76 | out.print("Delayed tasks (accumulated)"); |
---|
| 77 | out.println(delayedTasks); |
---|
| 78 | out.print("Failed requests (accumulated)"); |
---|
| 79 | out.println(failedRequests); |
---|
| 80 | out.print("Makespan (accumulated)"); |
---|
| 81 | out.println(makespan); |
---|
| 82 | out.print("Resources queue length (accumulated)"); |
---|
| 83 | out.println(taskQueueLength); |
---|
| 84 | out.print("Mean (accumulated) resource load"); |
---|
| 85 | out.println(resourceLoad); |
---|
| 86 | out.print("Mean (accumulated) reservation load"); |
---|
| 87 | out.println(reservationLoad); |
---|
| 88 | out.print("Task completion time (accumulated)"); |
---|
| 89 | out.println(taskCompletionTime); |
---|
| 90 | out.print("Task execution time (accumulated)"); |
---|
| 91 | out.println(taskExecutionTime); |
---|
| 92 | out.print("Task flow time (accumulated)"); |
---|
| 93 | out.println(taskFlowTime); |
---|
| 94 | out.print("Task waiting time (accumulated)"); |
---|
| 95 | out.println(taskWaitingTime); |
---|
| 96 | out.print("Task lateness (accumulated)"); |
---|
| 97 | out.println(taskLateness); |
---|
| 98 | out.print("Task tardiness (accumulated)"); |
---|
| 99 | out.println(taskTardiness); |
---|
| 100 | out.println(); |
---|
| 101 | out.close(); |
---|
| 102 | } |
---|
| 103 | |
---|
| 104 | public GSSAccumulator getAccumulatedResourceLoad() { |
---|
| 105 | GSSAccumulator resourceMeanLoad = new GSSAccumulator(); |
---|
| 106 | for (SimulationStatistics simStat : simulations) { |
---|
| 107 | GSSAccumulator simulationResTotalLoad = simStat.getStats(RESOURCES_TOTAL_LOAD); |
---|
| 108 | resourceMeanLoad.add(simulationResTotalLoad.getMean()); |
---|
| 109 | } |
---|
| 110 | return resourceMeanLoad; |
---|
| 111 | } |
---|
| 112 | |
---|
| 113 | public GSSAccumulator getAccumulatedReservationLoad(){ |
---|
| 114 | GSSAccumulator reservationMean = new GSSAccumulator(); |
---|
| 115 | for (SimulationStatistics simStat : simulations) { |
---|
| 116 | Accumulator simulationResvTotalLoad = simStat.getStats(RESOURCES_RESERVATION_LOAD); |
---|
| 117 | reservationMean.add(simulationResvTotalLoad.getMean()); |
---|
| 118 | } |
---|
| 119 | return reservationMean; |
---|
| 120 | } |
---|
| 121 | |
---|
| 122 | /*public GSSAccumulator getAccumulatedBokrerThroughput() { |
---|
| 123 | GSSAccumulator meanThroughput = new GSSAccumulator(); |
---|
| 124 | |
---|
| 125 | for (SimulationStatisticsNew simStat : simulations) { |
---|
| 126 | double simulationMeanThroughput = simStat.getBrokerStats().average(Sim_stat.THROUGHPUT); |
---|
| 127 | meanThroughput.add(simulationMeanThroughput); |
---|
| 128 | } |
---|
| 129 | return meanThroughput; |
---|
| 130 | }*/ |
---|
| 131 | |
---|
| 132 | public GSSAccumulator getAccumulatedJobFlowTime() { |
---|
| 133 | GSSAccumulator meanJobFlowTime = new GSSAccumulator(); |
---|
| 134 | for (SimulationStatistics simStat : simulations) { |
---|
| 135 | Accumulator simulationJobFlowTime = simStat.getStats(TASK_FLOW_TIME); |
---|
| 136 | meanJobFlowTime.add(simulationJobFlowTime.getMean()); |
---|
| 137 | } |
---|
| 138 | return meanJobFlowTime; |
---|
| 139 | } |
---|
| 140 | |
---|
| 141 | public GSSAccumulator getAccumulatedLateness() { |
---|
| 142 | GSSAccumulator meanLateness = new GSSAccumulator(); |
---|
| 143 | for (SimulationStatistics simStat : simulations) { |
---|
| 144 | Accumulator simulationLateness = simStat.getStats(TASK_LATENESS); |
---|
| 145 | meanLateness.add(simulationLateness.getMean()); |
---|
| 146 | } |
---|
| 147 | return meanLateness; |
---|
| 148 | } |
---|
| 149 | |
---|
| 150 | public GSSAccumulator getAccumulatedFailedRequests() { |
---|
| 151 | GSSAccumulator meanFailedRequests = new GSSAccumulator(); |
---|
| 152 | for (SimulationStatistics simStat : simulations) { |
---|
| 153 | Accumulator simulationFailedRequestes = simStat.getStats(FAILED_REQUESTS); |
---|
| 154 | meanFailedRequests.add(simulationFailedRequestes.getMean()); |
---|
| 155 | } |
---|
| 156 | return meanFailedRequests; |
---|
| 157 | } |
---|
| 158 | |
---|
| 159 | public GSSAccumulator getAccumulatedTardiness() { |
---|
| 160 | GSSAccumulator meanTardiness = new GSSAccumulator(); |
---|
| 161 | for (SimulationStatistics simStat : simulations) { |
---|
| 162 | Accumulator simulationJobTardiness = simStat.getStats(TASK_TARDINESS); |
---|
| 163 | meanTardiness.add(simulationJobTardiness.getMean()); |
---|
| 164 | } |
---|
| 165 | return meanTardiness; |
---|
| 166 | } |
---|
| 167 | |
---|
| 168 | public GSSAccumulator getAccumulatedDelayedTasks() { |
---|
| 169 | GSSAccumulator delayedTasks = new GSSAccumulator(); |
---|
| 170 | for (SimulationStatistics simStat : simulations) { |
---|
| 171 | Accumulator simulationDelayedTasks = simStat.getStats(DELAYED_TASKS); |
---|
| 172 | delayedTasks.add(simulationDelayedTasks.getMean()); |
---|
| 173 | } |
---|
| 174 | return delayedTasks; |
---|
| 175 | } |
---|
| 176 | |
---|
| 177 | public GSSAccumulator getAccumulatedCompletionTime() { |
---|
| 178 | GSSAccumulator meanJobCompletionTime = new GSSAccumulator(); |
---|
| 179 | |
---|
| 180 | for (SimulationStatistics simStat : simulations) { |
---|
| 181 | Accumulator simulationJobTurnaroundTime = simStat.getStats(TASK_COMPLETION_TIME); |
---|
| 182 | meanJobCompletionTime.add(simulationJobTurnaroundTime.getMean()); |
---|
| 183 | } |
---|
| 184 | return meanJobCompletionTime; |
---|
| 185 | } |
---|
| 186 | |
---|
| 187 | public GSSAccumulator getAccumulatedMakespan() { |
---|
| 188 | GSSAccumulator meanMakespan = new GSSAccumulator(); |
---|
| 189 | for (SimulationStatistics simStat : simulations) { |
---|
| 190 | meanMakespan.add(simStat.getStats(MAKESPAN).getMean()); |
---|
| 191 | } |
---|
| 192 | return meanMakespan; |
---|
| 193 | } |
---|
| 194 | |
---|
| 195 | public GSSAccumulator getAccumulatedWaitingTime() { |
---|
| 196 | GSSAccumulator meanWaitingTime = new GSSAccumulator(); |
---|
| 197 | for (SimulationStatistics simStat : simulations) |
---|
| 198 | meanWaitingTime.add(simStat.getStats(TASK_WAITING_TIME).getMean()); |
---|
| 199 | return meanWaitingTime; |
---|
| 200 | } |
---|
| 201 | |
---|
| 202 | public GSSAccumulator getAccumulatedJobExecutionTime() { |
---|
| 203 | GSSAccumulator meanJobExecutionTime = new GSSAccumulator(); |
---|
| 204 | for (SimulationStatistics simStat : simulations) |
---|
| 205 | meanJobExecutionTime.add(simStat.getStats(TASK_EXECUTION_TIME).getMean()); |
---|
| 206 | return meanJobExecutionTime; |
---|
| 207 | } |
---|
| 208 | |
---|
| 209 | public GSSAccumulator getAccumulatedQueueJobCount() { |
---|
| 210 | GSSAccumulator meanQueuJobCount = new GSSAccumulator(); |
---|
| 211 | for (SimulationStatistics simStat : simulations) |
---|
| 212 | meanQueuJobCount.add(simStat.getStats(RESOURCES_QUEUE_LENGTH).getMean()); |
---|
| 213 | return meanQueuJobCount; |
---|
| 214 | } |
---|
| 215 | |
---|
| 216 | } |
---|