Changeset 1362 for DCWoRMS/branches/coolemall/src/simulator/stats/implementation/DCWormsStatistics.java
- Timestamp:
- 06/03/14 15:12:11 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
DCWoRMS/branches/coolemall/src/simulator/stats/implementation/DCWormsStatistics.java
r1357 r1362 16 16 import java.util.HashMap; 17 17 import java.util.HashSet; 18 import java.util.LinkedList; 18 19 import java.util.List; 19 20 import java.util.Map; … … 78 79 import schedframe.resources.units.ResourceUnitName; 79 80 import schedframe.resources.units.StandardResourceUnitName; 81 import schedframe.scheduling.ExecutionHistoryItem; 80 82 import schedframe.scheduling.ResourceHistoryItem; 81 83 import schedframe.scheduling.Scheduler; … … 104 106 import eduni.simjava.Sim_stat; 105 107 import example.energy.coolemall.CoolEmAllTestbedMeasurements; 108 import gridsim.dcworms.DCWormsTags; 106 109 107 110 public class DCWormsStatistics implements SimulationStatistics { … … 407 410 } 408 411 409 pesStats = gatherPEStats (jr.getTasks());412 pesStats = gatherPEStatsMulti(jr.getTasks()); 410 413 peStatsPostProcessing(pesStats); 411 414 basicResLoad = calculatePELoad(pesStats); … … 763 766 Executable exec = (Executable) execTask; 764 767 765 List<ResourceHistoryItem> resHistItemList = exec.getUsedResources(); 766 if(resHistItemList.size() == 0) 768 769 LinkedList<ResourceHistoryItem> resourceHistory = exec.getAllocatedResources(); 770 if(resourceHistory.size() == 0) 767 771 continue; 768 Map<ResourceUnitName, ResourceUnit> res = resHistItemList.get(resHistItemList.size() - 1).getResourceUnits();772 Map<ResourceUnitName, ResourceUnit> res = exec.getAllocatedResources().getLast().getResourceUnits(); 769 773 ResourceUnit resUnit = res.get(StandardResourceUnitName.PE); 770 774 //ProcessingElements pes = (ProcessingElements) resUnit ; … … 820 824 } 821 825 return basicResStats; 826 } 827 828 private Map<String, List<ResStat>> gatherPEStatsMulti(ExecutablesList executables) { 829 830 Map<String, List<ResStat>> basicResStats = new TreeMap<String, List<ResStat>>(new MapPEIdComparator()); 831 for (ExecTask execTask:executables) { 832 Executable exec = (Executable) execTask; 833 834 LinkedList<ResourceHistoryItem> resourceHistory = exec.getAllocatedResources(); 835 if(resourceHistory.size() == 0) 836 continue; 837 838 for(int i = 0; i < resourceHistory .size(); i++){ 839 ResourceHistoryItem resHistItem = resourceHistory.get(i); 840 Map<ResourceUnitName, ResourceUnit> res = resHistItem.getResourceUnits(); 841 ResourceUnit resUnit = res.get(StandardResourceUnitName.PE); 842 //ProcessingElements pes = (ProcessingElements) resUnit ; 843 LinkedList<ExecutionHistoryItem> execHistory = exec.getExecHistory(); 844 long st = -1, et; 845 for(int j = 0; j < execHistory .size(); j++){ 846 ExecutionHistoryItem execHistItem = execHistory.get(j); 847 if(execHistItem.getStatus() == DCWormsTags.PAUSED || execHistItem.getResIndex() != i){ 848 continue; 849 } 850 if(st == -1){ 851 st = execHistItem.getTimeStamp().getMillis(); 852 } 853 854 if(j < execHistory.size() - 1 && (execHistory.get(j + 1).getResIndex() != execHistItem.getResIndex() || execHistory.get(j + 1).getStatus() == DCWormsTags.PAUSED) || j + 1 == execHistory.size()){ 855 if(j < execHistory.size() -1 && (execHistory.get(j + 1).getResIndex() != execHistItem.getResIndex() || execHistory.get(j + 1).getStatus() == DCWormsTags.PAUSED)) 856 et = execHistory.get(j + 1).getTimeStamp().getMillis(); 857 else et = Double.valueOf(exec.getFinishTime()).longValue() * MILLI_SEC; 858 if(resUnit instanceof ProcessingElements){ 859 ProcessingElements pes = (ProcessingElements) resUnit; 860 for(ComputingResource pe: pes){ 861 String peName = pe.getFullName(); 862 long startDate = st; 863 long endDate; 864 if(i == resourceHistory.size() - 1){ 865 endDate = Double.valueOf(exec.getFinishTime()).longValue() * MILLI_SEC; 866 }else { 867 endDate = et; 868 } 869 870 String appID = getAppId(execTask); 871 872 ResStat resStat = new ResStat(peName, pe.getType(), startDate, endDate, appID); 873 874 List<ResStat> resStats = basicResStats.get(peName); 875 if (resStats == null) { 876 resStats = new ArrayList<ResStat>(); 877 resStats.add(resStat); 878 basicResStats.put(peName, resStats); 879 } else { 880 resStats.add(resStat); 881 } 882 883 String uniqueTaskID = getUniqueTaskId(execTask); 884 885 Set<ComputingResource> peNames = task_processorsMap.get(uniqueTaskID); 886 if (peNames == null) { 887 peNames = new HashSet<ComputingResource>(); 888 peNames.add(pe); 889 task_processorsMap.put(uniqueTaskID, peNames); 890 } else { 891 peNames.add(pe); 892 } 893 894 try{ 895 double usefulWork = execTask.getResourceConsumptionProfile().getUsefulWork()/pes.size(); 896 usefulWork = ((et - st) / (1000 * getExecutionTime(execTask))) * usefulWork; 897 GSSAccumulator uwAcc; 898 if(metCalc.getMetricsData().containsKey("UW_" + pe.getFullName())){ 899 uwAcc = metCalc.getMetricsData().get("UW_" + pe.getFullName()).get(0); 900 uwAcc.add(usefulWork); 901 } else { 902 uwAcc = new GSSAccumulator(); 903 uwAcc.add(usefulWork); 904 metCalc.addMetricsData("UW_" + pe.getFullName(), uwAcc); 905 } 906 } catch (Exception e){ 907 908 } 909 910 } 911 } 912 st = -1; 913 } 914 } 915 } 916 } 917 return basicResStats; 918 } 919 920 private double getExecutionTime(ExecTask execTask) { 921 double executionTime = 0; 922 long previousTimestamp = 0; 923 int previousStatus = DCWormsTags.CREATED; 924 for(ExecutionHistoryItem execHistItem: execTask.getExecHistory()){ 925 if(previousStatus == DCWormsTags.INEXEC){ 926 executionTime = executionTime + (execHistItem.getTimeStamp().getMillis()/1000 - previousTimestamp); 927 } 928 previousTimestamp = execHistItem.getTimeStamp().getMillis()/1000; 929 previousStatus = execHistItem.getStatus(); 930 } 931 return executionTime; 932 //return task.getFinishTime() - task.getExecStartTime(); 822 933 } 823 934
Note: See TracChangeset
for help on using the changeset viewer.