- Timestamp:
- 10/10/12 14:02:11 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
DCWoRMS/trunk/src/simulator/stats/implementation/DCWormsStatistics.java
r495 r496 131 131 132 132 //RESOURCES 133 protected Timetable ganttDiagramPeTimetable; 133 protected Map<String, List<ResStat>> basicResStats; 134 protected Map<String, Double> basicResLoad; 135 136 protected Map<String, TimetableEventSource> peGanttMap; 137 protected Map<String, TimetableEventGroup> taskGanttMap; 138 139 protected Timetable ganttDiagramTimetable; 134 140 protected Map<ResourceType, List<XYDataset>> resourcePowerUsageDiagrams; 135 141 protected Map<ResourceType, List<XYDataset>> resourceAirFlowDiagrams; 136 142 protected Map<ResourceType, List<XYDataset>> resourceLoadDiagrams; 137 protected Map<String,List<ResStat>> basicResStats;138 protected HashMap<String, Double> basicResLoad;139 140 protected Map<String, TimetableEventSource> peGanttMap;141 protected Map<String, TimetableEventGroup> taskGanttMap;142 143 143 144 //TASKS … … 256 257 resourceAirFlowDiagrams = new HashMap<ResourceType, List<XYDataset>>(); 257 258 258 ganttDiagram PeTimetable = new Timetable(new FixedMillisecond(259 ganttDiagramTimetable = new Timetable(new FixedMillisecond( 259 260 startSimulationTime), new FixedMillisecond(endSimulationTime)); 260 261 … … 310 311 for(ComputingResource resource: resources){ 311 312 ResourceUsageStats resourceUsage = null; 312 Resource EnergyStats energyUsage = null;313 ResourcePowerStats energyUsage = null; 313 314 ResourceAirFlowStats airFlow = null; 314 315 if(type_stats.get(resourceName).contains(Stats.textLoad)){ 315 316 resourceUsage = gatherResourceLoadStats(resource, basicResStats); 316 resourceUsage.setMean Usage(calculateResourceLoad(resource, basicResLoad));317 resourceUsage.setMeanValue(calculateResourceLoad(resource, basicResLoad)); 317 318 if (resourceLoadStatsFile != null) { 318 319 Object txt = resourceUsage.serialize(serializer); … … 326 327 } 327 328 if(type_stats.get(resourceName).contains(Stats.textEnergy)){ 328 energyUsage = gatherResource EnergyStats(resource);329 energyUsage.setMean Usage(calculateEnergyLoad(energyUsage));330 energyUsage.setSum Usage(energyUsage.getMeanUsage() * (endSimulationTime - startSimulationTime) / (3600 * MILLI_SEC));329 energyUsage = gatherResourcePowerConsumptionStats(resource); 330 energyUsage.setMeanValue(calculateMeanValue(energyUsage)); 331 energyUsage.setSumValue(energyUsage.getMeanValue() * (endSimulationTime - startSimulationTime) / (3600 * MILLI_SEC)); 331 332 332 333 EnergyExtension een = (EnergyExtension )(resource.getExtensionList().getExtension(ExtensionType.ENERGY_EXTENSION)); 333 334 if(resourceController.getComputingResources().contains(resource)) { 334 335 if( een != null /*&& een.getPp() != null*/ ){ 335 accStats.meanEnergyUsage.add(energyUsage. meanUsage);336 accStats.meanEnergyUsage.add(energyUsage.getMeanValue()); 336 337 } 337 338 … … 348 349 } 349 350 if(top == true){ 350 accStats.meanEnergyUsage.add(energyUsage. meanUsage);351 accStats.meanEnergyUsage.add(energyUsage.getMeanValue()); 351 352 } 352 353 } … … 359 360 360 361 if (configuration.creatediagrams_energyusage) { 361 createResourceEnergy GanttDiagram(energyUsage);362 createResourceEnergyDiagramData(energyUsage); 362 363 } 363 364 } … … 365 366 if(type_stats.get(resourceName).contains(Stats.textAirFlow)){ 366 367 airFlow = gatherResourceAirFlowStats(resource); 367 airFlow.setMean Usage(calculateAirFlowLoad(airFlow));368 airFlow.setSum Usage(airFlow.getMeanUsage() * (endSimulationTime - startSimulationTime) / (3600 * MILLI_SEC));368 airFlow.setMeanValue(calculateMeanValue(airFlow)); 369 airFlow.setSumValue(airFlow.getMeanValue() * (endSimulationTime - startSimulationTime) / (3600 * MILLI_SEC)); 369 370 370 371 EnergyExtension een = (EnergyExtension)(resource.getExtensionList().getExtension(ExtensionType.ENERGY_EXTENSION)); … … 397 398 398 399 if (configuration.creatediagrams_airflow) { 399 createResourceAirFlow GanttDiagram(airFlow);400 createResourceAirFlowDiagramData(airFlow); 400 401 } 401 402 } … … 406 407 saveResourceGanttDiagrams(); 407 408 createAccumulatedResourceSimulationStatistic(); 409 408 410 if (airFlowStatsFile != null) { 409 411 airFlowStatsFile.close(); … … 416 418 } 417 419 } 418 419 private double getSchedulerQueueStats(Scheduler scheduler) { 420 421 Sim_stat stats = scheduler.get_stat(); 422 List<Object[]> measures = stats.get_measures(); 423 for (Object[] info : measures) { 424 String measure = (String) info[0]; 425 if (measure 426 .startsWith(DCWormsConstants.TASKS_QUEUE_LENGTH_MEASURE_NAME)) { 427 return stats.average(measure); 428 } 429 } 430 return 0; 431 } 420 432 421 433 422 private void peStatsPostProcessing(Map<String, List<ResStat>> basicResStats){ … … 517 506 } 518 507 } 519 for(Long key: usageStats.get Usage().keySet()){520 Double value = usageStats.get Usage().get(key)/cnt;521 usageStats.get Usage().put(key,value);508 for(Long key: usageStats.getHistory().keySet()){ 509 Double value = usageStats.getHistory().get(key)/cnt; 510 usageStats.getHistory().put(key, 100*value); 522 511 } 523 512 … … 525 514 } 526 515 527 private TreeMap<Long, Double> createResourceLoadData(ResourceUsageStats usageStats, List<ResStat> resStats) {528 529 TreeMap<Long, Double> ganttData = (TreeMap<Long, Double>)usageStats.get Usage();516 private Map<Long, Double> createResourceLoadData(ResourceUsageStats usageStats, List<ResStat> resStats) { 517 518 TreeMap<Long, Double> ganttData = (TreeMap<Long, Double>)usageStats.getHistory(); 530 519 for (ResStat resStat : resStats) { 531 520 … … 575 564 576 565 577 private Resource EnergyStats gatherResourceEnergyStats(ComputingResource resource) {566 private ResourcePowerStats gatherResourcePowerConsumptionStats(ComputingResource resource) { 578 567 double power = 0; 579 Resource EnergyStats resEnergyUsage = new ResourceEnergyStats(resource.getName(), resource.getType(), "resourceEnergyStats");580 Map<Long, Double> usage = resEnergyUsage.get Energy();568 ResourcePowerStats resEnergyUsage = new ResourcePowerStats(resource.getName(), resource.getType(), "resourcePowerConsumptionStats"); 569 Map<Long, Double> usage = resEnergyUsage.getHistory(); 581 570 582 571 ExtensionList extensionList = resource.getExtensionList(); … … 613 602 614 603 ResourceAirFlowStats resAirFlow = new ResourceAirFlowStats(resource.getName(), resource.getType(), "resourceAirFlowStats"); 615 Map<Long, Double> airFlow = resAirFlow.get AirFlow();604 Map<Long, Double> airFlow = resAirFlow.getHistory(); 616 605 617 606 ExtensionList extensionList = resource.getExtensionList(); … … 625 614 if(airFlowHistory.size() == 0) 626 615 break; 627 long lastTime = DateTimeUtilsExt.getOffsetTime().getTimeInMillis();628 616 long endSimulationTime = DateTimeUtilsExt.currentTimeMillis(); 629 double lastAirFlow = 0;630 617 airFlowHistory.add(new AirFlowValue(endSimulationTime, ee.getAirFlowProfile().getAirThroughputHistory().get(ee.getAirFlowProfile().getAirThroughputHistory().size()-1).getValue())); 631 618 for(AirFlowValue af:airFlowHistory){ 632 619 airFlow.put(af.getTimestamp(), af.getValue()); 633 634 lastAirFlow = af.getValue();635 lastTime = af.getTimestamp();636 620 } 637 621 } … … 641 625 } 642 626 643 private void createResource EnergyGanttDiagram(ResourceEnergyStats powerUsage) {644 645 XYDataset dataset = createResource EnergyGanttDataSet(powerUsage,627 private void createResourceLoadDiagram(ResourceUsageStats resLoadStats) { 628 629 XYDataset dataset = createResourceChartDataSet(resLoadStats, 646 630 startSimulationTime, endSimulationTime); 647 648 List<XYDataset> energyDiagram = resourcePowerUsageDiagrams.get(powerUsage.getResourceType());649 if( energyDiagram == null){650 energyDiagram = new ArrayList<XYDataset>();651 energyDiagram.add(dataset);652 resource PowerUsageDiagrams.put(powerUsage.getResourceType(), energyDiagram);631 632 List<XYDataset> loadDiagram = resourceLoadDiagrams.get(resLoadStats.getResourceType()); 633 if(loadDiagram == null){ 634 loadDiagram = new ArrayList<XYDataset>(); 635 loadDiagram.add(dataset); 636 resourceLoadDiagrams.put(resLoadStats.getResourceType(), loadDiagram); 653 637 } else { 654 energyDiagram.add(dataset); 655 } 656 657 } 658 659 private void createResourceAirFlowGanttDiagram(ResourceAirFlowStats airFlow) { 660 661 XYDataset dataset = createResourceAirFlowGanttDataSet(airFlow, 638 loadDiagram.add(dataset); 639 } 640 } 641 642 private void createResourceEnergyDiagramData(ResourceDynamicStats powerConsumptionStats) { 643 644 XYDataset dataset = createResourceChartDataSet(powerConsumptionStats, 662 645 startSimulationTime, endSimulationTime); 663 646 664 List<XYDataset> airFlowDiagram = resourceAirFlowDiagrams.get(airFlow.getResourceType());665 if( airFlowDiagram== null){666 airFlowDiagram= new ArrayList<XYDataset>();667 airFlowDiagram.add(dataset);668 resource AirFlowDiagrams.put(airFlow.getResourceType(), airFlowDiagram);647 List<XYDataset> energyDiagramData = resourcePowerUsageDiagrams.get(powerConsumptionStats.getResourceType()); 648 if(energyDiagramData == null){ 649 energyDiagramData = new ArrayList<XYDataset>(); 650 energyDiagramData.add(dataset); 651 resourcePowerUsageDiagrams.put(powerConsumptionStats.getResourceType(), energyDiagramData); 669 652 } else { 670 airFlowDiagram.add(dataset); 671 } 672 673 } 674 675 private XYDataset createResourceEnergyGanttDataSet( 676 ResourceEnergyStats energyUsage, long start, long end) { 677 678 TreeMap<Long, Double> ganttdata = createResourceEnergyGanttData(energyUsage); 653 energyDiagramData.add(dataset); 654 } 655 } 656 657 private void createResourceAirFlowDiagramData(ResourceDynamicStats airFlowStats) { 658 659 XYDataset dataset = createResourceChartDataSet(airFlowStats, 660 startSimulationTime, endSimulationTime); 661 662 List<XYDataset> airFlowDiagramData = resourceAirFlowDiagrams.get(airFlowStats.getResourceType()); 663 if(airFlowDiagramData == null){ 664 airFlowDiagramData = new ArrayList<XYDataset>(); 665 airFlowDiagramData.add(dataset); 666 resourceAirFlowDiagrams.put(airFlowStats.getResourceType(), airFlowDiagramData); 667 } else { 668 airFlowDiagramData.add(dataset); 669 } 670 } 671 672 private XYDataset createResourceChartDataSet( 673 ResourceDynamicStats dynamicStats, long start, long end) { 674 675 Map<Long, Double> chartData = getResourceChartRawData(dynamicStats); 679 676 XYSeriesCollection dataset = new XYSeriesCollection(); 680 XYSeries data = new XYSeries( energyUsage.getResourceName(), false, true);677 XYSeries data = new XYSeries(dynamicStats.getResourceName(), false, true); 681 678 //data.add(start, 0); 682 for (Long key : ganttdata.keySet()) {683 Double val = ganttdata.get(key);679 for (Long key : chartData.keySet()) { 680 Double val = chartData.get(key); 684 681 data.add(key, val); 685 682 } … … 689 686 } 690 687 691 private TreeMap<Long, Double> createResourceEnergyGanttData( 692 ResourceEnergyStats energyUsage) { 693 694 Map<Long, Double> energy = energyUsage.getEnergy(); 695 TreeMap<Long, Double> ganttData = new TreeMap<Long, Double>(); 696 for (Long euKey : energy.keySet()) { 697 698 ganttData.put(euKey, energy.get(euKey)); 699 } 700 return ganttData; 701 } 702 703 private XYDataset createResourceAirFlowGanttDataSet( 704 ResourceAirFlowStats airFlowStats, long start, long end) { 705 706 TreeMap<Long, Double> ganttdata = createResourceAirFlowGanttData(airFlowStats); 707 XYSeriesCollection dataset = new XYSeriesCollection(); 708 XYSeries data = new XYSeries(airFlowStats.getResourceName(), false, true); 709 //data.add(start, 0); 710 for (Long key : ganttdata.keySet()) { 711 Double val = ganttdata.get(key); 712 data.add(key, val); 713 } 714 data.add(end, 0); 715 dataset.addSeries(data); 716 return dataset; 717 } 718 719 private TreeMap<Long, Double> createResourceAirFlowGanttData( 720 ResourceAirFlowStats airFlowStats) { 721 722 Map<Long, Double> airFlow = airFlowStats.getAirFlow(); 723 TreeMap<Long, Double> ganttData = new TreeMap<Long, Double>(); 724 for (Long afKey : airFlow.keySet()) { 725 ganttData.put(afKey, airFlow.get(afKey)); 726 } 727 return ganttData; 688 private Map<Long, Double> getResourceChartRawData( 689 ResourceDynamicStats dynamicStats) { 690 691 Map<Long, Double> history = dynamicStats.getHistory(); 692 Map<Long, Double> chartData = new TreeMap<Long, Double>(); 693 for (Long key : history.keySet()) { 694 chartData.put(key, history.get(key)); 695 } 696 return chartData; 728 697 } 729 698 730 699 private boolean saveResourceGanttDiagrams() { 731 JFreeChart resourceDiagram = null; 732 JFreeChart peDiagram = null; 733 JFreeChart resourceEnergyDiagram = null; 734 JFreeChart resourceAirFlowDiagram = null; 700 735 701 if (!generateDiagrams) 736 702 return false; … … 745 711 + "\" at " + Calendar.getInstance().getTime().toString()); 746 712 747 713 JFreeChart peDiagram = null; 748 714 if (configuration.creatediagrams_processors) { 749 peDiagram = getP eGanttDiagram(chartName, subtitle,715 peDiagram = getPEGanttDiagram(chartName, subtitle, 750 716 simulationTime); 751 717 if (!saveCategoryChart(peDiagram, fileName + "Gantt", … … 754 720 } 755 721 722 JFreeChart resourceLoadDiagram = null; 756 723 if (configuration.creatediagrams_resources) { 724 String axisName = "UTILIZATION [%]"; 757 725 for(ResourceType resType: resourceLoadDiagrams.keySet()){ 758 resource Diagram = getResourcesLoadDiagram(resType, chartName, subtitle,759 s imulationTime);760 if (!saveXYPlotChart(resource Diagram, fileName + "Resources Load - "+resType))726 resourceLoadDiagram = getResourceDynamicDiagram(resourceLoadDiagrams.get(resType), simulationTime, chartName, 727 subtitle, axisName); 728 if (!saveXYPlotChart(resourceLoadDiagram, fileName + "Resources Load - "+resType)) 761 729 return false; 762 730 } 763 764 } 731 } 732 733 JFreeChart resourceEnergyDiagram = null; 765 734 if (configuration.creatediagrams_energyusage) { 735 String axisName = "POWER [W]"; 766 736 for(ResourceType resType: resourcePowerUsageDiagrams.keySet()){ 767 resourceEnergyDiagram = getResource sEnergyDiagram(resType, chartName,768 subtitle, simulationTime);737 resourceEnergyDiagram = getResourceDynamicDiagram(resourcePowerUsageDiagrams.get(resType), simulationTime, chartName, 738 subtitle, axisName); 769 739 if (!saveXYPlotChart(resourceEnergyDiagram, fileName + "Energy - "+resType)) 770 740 return false; … … 772 742 } 773 743 774 744 JFreeChart resourceAirFlowDiagram = null; 775 745 if (configuration.creatediagrams_airflow) { 746 String axisName = "AIR FLOW [m^3/min]"; 776 747 for(ResourceType resType: resourceAirFlowDiagrams.keySet()){ 777 resourceAirFlowDiagram = getResource sAirFlowDiagram(resType, chartName,778 subtitle, simulationTime);748 resourceAirFlowDiagram = getResourceDynamicDiagram(resourceAirFlowDiagrams.get(resType), simulationTime, chartName, 749 subtitle, axisName); 779 750 if (!saveXYPlotChart(resourceAirFlowDiagram, fileName + "AirThroughput - "+resType)) 780 751 return false; … … 784 755 } 785 756 786 private JFreeChart get ResourcesLoadDiagram(ResourceType resType,String chartName, Title subtitle,757 private JFreeChart getPEGanttDiagram(String chartName, Title subtitle, 787 758 String simulationTime) { 788 String cpu = "UTILIZATION [%]"; 759 String processors = "Processing Elements"; 760 boolean tooltip = true; 761 boolean legend = true; 762 JFreeChart chart = TimetableChartFactory.createTimetableChart( 763 chartName, processors, simulationTime, 764 ganttDiagramTimetable, legend, tooltip); 765 chart.addSubtitle(subtitle); 766 TimetableRenderer rend = (TimetableRenderer) chart.getCategoryPlot() 767 .getRenderer(); 768 rend.setBackgroundBarPaint(null); 769 return chart; 770 } 771 772 private JFreeChart getResourceDynamicDiagram(List<XYDataset> diagramData, String simulationTime, String chartName, Title subtitle, 773 String axisName) { 789 774 boolean urls = false; 790 775 boolean tooltip = true; … … 794 779 JFreeChart chart = null; 795 780 796 List<XYDataset> loadDiagram = resourceLoadDiagrams.get(resType); 797 for (XYDataset dataset : loadDiagram) { 781 for (XYDataset dataset : diagramData) { 798 782 JFreeChart tChart = ChartFactory.createXYStepAreaChart("", "", 799 null, dataset, PlotOrientation.VERTICAL, legend, tooltip, 800 urls); 783 null, dataset, PlotOrientation.VERTICAL, legend, tooltip, urls); 801 784 XYPlot tPlot = tChart.getXYPlot(); 802 NumberAxis yAxis = new NumberAxis( cpu);785 NumberAxis yAxis = new NumberAxis(axisName); 803 786 yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); 804 787 tPlot.setRangeAxis(yAxis); … … 813 796 return chart; 814 797 } 815 816 private JFreeChart getResourcesEnergyDiagram(ResourceType resType, String chartName,817 Title subtitle, String simulationTime) {818 String energy = "POWER [W]";819 boolean urls = false;820 boolean tooltip = true;821 boolean legend = true;822 CombinedDomainXYPlot cPlot = new CombinedDomainXYPlot();823 DateAxis xAxis = new DateAxis(simulationTime);824 825 List<XYDataset> energyDiagram = resourcePowerUsageDiagrams.get(resType);826 for (XYDataset dataset : energyDiagram) {827 828 JFreeChart tChart = ChartFactory.createXYStepAreaChart("", "",829 null, dataset, PlotOrientation.VERTICAL, legend, tooltip,830 urls);831 832 XYPlot tPlot = tChart.getXYPlot();833 NumberAxis yAxis = new NumberAxis(energy);834 yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());835 tPlot.setRangeAxis(yAxis);836 XYStepAreaRenderer rend = (XYStepAreaRenderer) tPlot.getRenderer();837 rend.setShapesVisible(false);838 cPlot.add(tPlot);839 }840 cPlot.setDomainAxis(xAxis);841 cPlot.setDomainAxisLocation(AxisLocation.TOP_OR_LEFT);842 JFreeChart chart = new JFreeChart(chartName, cPlot);843 chart.addSubtitle(subtitle);844 return chart;845 }846 847 private JFreeChart getResourcesAirFlowDiagram(ResourceType resType, String chartName,848 Title subtitle, String simulationTime) {849 String airFlow = "AIR FLOW [m^3/min]";850 boolean urls = false;851 boolean tooltip = true;852 boolean legend = true;853 CombinedDomainXYPlot cPlot = new CombinedDomainXYPlot();854 DateAxis xAxis = new DateAxis(simulationTime);855 856 List<XYDataset> airFlowDiagram = resourceAirFlowDiagrams.get(resType);857 for (XYDataset dataset : airFlowDiagram) {858 859 JFreeChart tChart = ChartFactory.createXYStepAreaChart("", "",860 null, dataset, PlotOrientation.VERTICAL, legend, tooltip,861 urls);862 863 XYPlot tPlot = tChart.getXYPlot();864 NumberAxis yAxis = new NumberAxis(airFlow);865 yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());866 tPlot.setRangeAxis(yAxis);867 XYStepAreaRenderer rend = (XYStepAreaRenderer) tPlot.getRenderer();868 rend.setShapesVisible(false);869 cPlot.add(tPlot);870 }871 cPlot.setDomainAxis(xAxis);872 cPlot.setDomainAxisLocation(AxisLocation.TOP_OR_LEFT);873 JFreeChart chart = new JFreeChart(chartName, cPlot);874 chart.addSubtitle(subtitle);875 return chart;876 }877 878 879 private JFreeChart getPeGanttDiagram(String chartName, Title subtitle,880 String simulationTime) {881 String processors = "Processing Elements";882 boolean tooltip = true;883 boolean legend = true;884 JFreeChart chart = TimetableChartFactory.createTimetableChart(885 chartName, processors, simulationTime,886 ganttDiagramPeTimetable, legend, tooltip);887 chart.addSubtitle(subtitle);888 TimetableRenderer rend = (TimetableRenderer) chart.getCategoryPlot()889 .getRenderer();890 rend.setBackgroundBarPaint(null);891 return chart;892 }893 894 798 895 799 private boolean saveXYPlotChart(JFreeChart c, String fileName) { … … 932 836 for(String peName: basicResStats.keySet()){ 933 837 TimetableEventSource pe = new TimetableEventSource(peName); 934 ganttDiagram PeTimetable.addEventSource(pe);838 ganttDiagramTimetable.addEventSource(pe); 935 839 peGanttMap.put(peName, pe); 936 840 for(ResStat resStat: basicResStats.get(peName)){ … … 948 852 task = new TimetableEventGroup(resStat.getTaskID()); 949 853 taskGanttMap.put(resStat.getTaskID(), task); 950 ganttDiagram PeTimetable.addEventGroup(task);951 } 952 ganttDiagram PeTimetable.addEvent(pe, task,854 ganttDiagramTimetable.addEventGroup(task); 855 } 856 ganttDiagramTimetable.addEvent(pe, task, 953 857 new FixedMillisecond(startDate), new FixedMillisecond(endDate)); 954 858 } … … 956 860 } 957 861 958 private void createResourceLoadDiagram(ResourceUsageStats resStats) { 959 960 XYDataset dataset = createResourceLoadDataSet(resStats); 961 962 List<XYDataset> loadDiagram = resourceLoadDiagrams.get(resStats.getResourceType()); 963 if(loadDiagram == null){ 964 loadDiagram = new ArrayList<XYDataset>(); 965 loadDiagram.add(dataset); 966 resourceLoadDiagrams.put(resStats.getResourceType(), loadDiagram); 967 } else { 968 loadDiagram.add(dataset); 969 } 970 } 971 972 private XYDataset createResourceLoadDataSet(ResourceUsageStats resStats) { 973 974 XYSeriesCollection dataset = new XYSeriesCollection(); 975 XYSeries data = new XYSeries(resStats.resourceName, false, true); 976 Map<Long, Double> usage = resStats.getUsage(); 977 978 for (Long key : usage.keySet()) { 979 Double val = usage.get(key); 980 double newv = 100 * val; 981 //System.out.println(newv+":"+val+";"+basicResStats.size()); 982 data.add(key, new Double(newv)); 983 } 984 dataset.addSeries(data); 985 return dataset; 986 } 862 987 863 988 864 private void createAccumulatedResourceSimulationStatistic() { … … 1014 890 } 1015 891 1016 private Double calculateResourceLoad(ComputingResource resource, HashMap<String, Double> peLoad ){892 private Double calculateResourceLoad(ComputingResource resource, Map<String, Double> peLoad ){ 1017 893 int peCnt = 0; 1018 894 double sum = 0; … … 1033 909 return sum/peCnt; 1034 910 } 1035 1036 private double calculateEnergyLoad(ResourceEnergyStats resEnergyStats ){ 1037 double meanEnergyUsage = 0; 911 912 913 private double calculateMeanValue(ResourceDynamicStats resDynamicStats ){ 914 double meanValue = 0; 1038 915 long time = 0; 1039 double usage = 0; 1040 Map<Long, Double> enUsage = resEnergyStats.getEnergy(); 1041 for (Long key : enUsage.keySet()) { 916 double value = 0; 917 918 Map<Long, Double> history = resDynamicStats.getHistory(); 919 for (Long key : history.keySet()) { 1042 920 1043 921 if (time != 0) { 1044 meanEnergyUsage += (usage * (key - time)) 1045 / (endSimulationTime - startSimulationTime); 1046 922 meanValue += (value * (key - time)) / (endSimulationTime - startSimulationTime); 1047 923 time = key; 1048 924 } else { 1049 925 time = key; 1050 926 } 1051 usage = (double) enUsage.get(key); 1052 } 1053 return meanEnergyUsage; 1054 } 1055 1056 private double calculateAirFlowLoad(ResourceAirFlowStats resAirFlowStats ){ 1057 double meanAirFlow = 0; 1058 long time = 0; 1059 double usage = 0; 1060 Map<Long, Double> airFlow = resAirFlowStats.getAirFlow(); 1061 for (Long key : airFlow.keySet()) { 1062 1063 if (time != 0) { 1064 meanAirFlow += (usage * (key - time)) 1065 / (endSimulationTime - startSimulationTime); 1066 1067 time = key; 1068 } else { 1069 time = key; 1070 } 1071 usage = (double) airFlow.get(key); 1072 } 1073 return meanAirFlow; 1074 } 1075 1076 1077 /*private void createPEGanttDiagram(String peName, 1078 String uniqueTaskID, Map<String, Object> historyItem) { 1079 TimetableEventSource pe = peGanttMap.get(peName); 1080 if(pe == null){ 1081 pe = new TimetableEventSource(peName); 1082 ganttDiagramPETimetable.addEventSource(pe); 1083 peGanttMap.put(peName, pe); 1084 } 1085 TimetableEventGroup task = taskGanttMap.get(uniqueTaskID); 1086 long startDate = ((DateTime) historyItem.get(GssimConstants.START_TIME)) 1087 .getMillis(); 1088 long endDate = ((DateTime) historyItem.get(GssimConstants.END_TIME)) 1089 .getMillis(); 1090 if (task == null) { 1091 task = new TimetableEventGroup(uniqueTaskID); 1092 taskGanttMap.put(uniqueTaskID, task); 1093 ganttDiagramPETimetable.addEventGroup(task); 1094 } 1095 ganttDiagramPETimetable.addEvent(pe, task, 1096 new FixedMillisecond(startDate), new FixedMillisecond(endDate)); 1097 }*/ 927 value = history.get(key); 928 } 929 return meanValue; 930 } 931 932 933 934 935 936 1098 937 1099 938 … … 1194 1033 } 1195 1034 1035 private double getSchedulerQueueStats(Scheduler scheduler) { 1036 1037 Sim_stat stats = scheduler.get_stat(); 1038 List<Object[]> measures = stats.get_measures(); 1039 for (Object[] info : measures) { 1040 String measure = (String) info[0]; 1041 if (measure 1042 .startsWith(DCWormsConstants.TASKS_QUEUE_LENGTH_MEASURE_NAME)) { 1043 return stats.average(measure); 1044 } 1045 } 1046 return 0; 1047 } 1048 1196 1049 private TaskStats createTaskStats(Executable task) { 1197 1050 TaskStats taskStats = new TaskStats(task, startSimulationTime); … … 1425 1278 1426 1279 public int compare(JobInterface<?> o1, JobInterface<?> o2) { 1427 1428 1280 Integer o1int; 1429 1281 Integer o2int; … … 1435 1287 return o1.getId().compareTo(o2.getId()); 1436 1288 } 1437 1438 1289 } 1439 1290 } … … 1481 1332 class ResStat{ 1482 1333 1483 1484 1334 public long getStartDate() { 1485 1335 return startDate;
Note: See TracChangeset
for help on using the changeset viewer.