Ignore:
Timestamp:
10/10/12 14:02:11 (13 years ago)
Author:
wojtekp
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • DCWoRMS/trunk/src/simulator/stats/implementation/DCWormsStatistics.java

    r495 r496  
    131131         
    132132        //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; 
    134140        protected Map<ResourceType, List<XYDataset>> resourcePowerUsageDiagrams; 
    135141        protected Map<ResourceType, List<XYDataset>> resourceAirFlowDiagrams; 
    136142        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; 
    142143         
    143144        //TASKS 
     
    256257                resourceAirFlowDiagrams = new HashMap<ResourceType, List<XYDataset>>(); 
    257258                 
    258                 ganttDiagramPeTimetable = new Timetable(new FixedMillisecond( 
     259                ganttDiagramTimetable = new Timetable(new FixedMillisecond( 
    259260                                startSimulationTime), new FixedMillisecond(endSimulationTime)); 
    260261                 
     
    310311                                for(ComputingResource resource: resources){ 
    311312                                        ResourceUsageStats resourceUsage = null; 
    312                                         ResourceEnergyStats energyUsage = null; 
     313                                        ResourcePowerStats energyUsage = null; 
    313314                                        ResourceAirFlowStats airFlow = null; 
    314315                                        if(type_stats.get(resourceName).contains(Stats.textLoad)){ 
    315316                                                resourceUsage = gatherResourceLoadStats(resource, basicResStats); 
    316                                                 resourceUsage.setMeanUsage(calculateResourceLoad(resource, basicResLoad)); 
     317                                                resourceUsage.setMeanValue(calculateResourceLoad(resource, basicResLoad)); 
    317318                                                if (resourceLoadStatsFile != null) { 
    318319                                                        Object txt = resourceUsage.serialize(serializer); 
     
    326327                                        } 
    327328                                        if(type_stats.get(resourceName).contains(Stats.textEnergy)){ 
    328                                                 energyUsage = gatherResourceEnergyStats(resource); 
    329                                                 energyUsage.setMeanUsage(calculateEnergyLoad(energyUsage)); 
    330                                                 energyUsage.setSumUsage(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)); 
    331332                                                 
    332333                                                EnergyExtension een = (EnergyExtension )(resource.getExtensionList().getExtension(ExtensionType.ENERGY_EXTENSION)); 
    333334                                                if(resourceController.getComputingResources().contains(resource)) { 
    334335                                                        if( een != null /*&& een.getPp() != null*/ ){ 
    335                                                                 accStats.meanEnergyUsage.add(energyUsage.meanUsage); 
     336                                                                accStats.meanEnergyUsage.add(energyUsage.getMeanValue()); 
    336337                                                        } 
    337338 
     
    348349                                                        } 
    349350                                                        if(top == true){ 
    350                                                                 accStats.meanEnergyUsage.add(energyUsage.meanUsage); 
     351                                                                accStats.meanEnergyUsage.add(energyUsage.getMeanValue()); 
    351352                                                        } 
    352353                                                } 
     
    359360 
    360361                                                if (configuration.creatediagrams_energyusage) { 
    361                                                         createResourceEnergyGanttDiagram(energyUsage); 
     362                                                        createResourceEnergyDiagramData(energyUsage); 
    362363                                                } 
    363364                                        } 
     
    365366                                        if(type_stats.get(resourceName).contains(Stats.textAirFlow)){ 
    366367                                                airFlow = gatherResourceAirFlowStats(resource); 
    367                                                 airFlow.setMeanUsage(calculateAirFlowLoad(airFlow)); 
    368                                                 airFlow.setSumUsage(airFlow.getMeanUsage() * (endSimulationTime - startSimulationTime) / (3600 * MILLI_SEC)); 
     368                                                airFlow.setMeanValue(calculateMeanValue(airFlow)); 
     369                                                airFlow.setSumValue(airFlow.getMeanValue() * (endSimulationTime - startSimulationTime) / (3600 * MILLI_SEC)); 
    369370                                                 
    370371                                                EnergyExtension een = (EnergyExtension)(resource.getExtensionList().getExtension(ExtensionType.ENERGY_EXTENSION)); 
     
    397398 
    398399                                                if (configuration.creatediagrams_airflow) { 
    399                                                         createResourceAirFlowGanttDiagram(airFlow); 
     400                                                        createResourceAirFlowDiagramData(airFlow); 
    400401                                                } 
    401402                                        } 
     
    406407                saveResourceGanttDiagrams(); 
    407408                createAccumulatedResourceSimulationStatistic(); 
     409                 
    408410                if (airFlowStatsFile != null) { 
    409411                        airFlowStatsFile.close(); 
     
    416418                } 
    417419        } 
    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 
    432421         
    433422        private void peStatsPostProcessing(Map<String, List<ResStat>> basicResStats){ 
     
    517506                        } 
    518507                } 
    519                 for(Long key: usageStats.getUsage().keySet()){ 
    520                         Double value = usageStats.getUsage().get(key)/cnt; 
    521                         usageStats.getUsage().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); 
    522511                } 
    523512 
     
    525514        } 
    526515         
    527         private TreeMap<Long, Double> createResourceLoadData(ResourceUsageStats usageStats, List<ResStat> resStats) { 
    528  
    529                 TreeMap<Long, Double> ganttData = (TreeMap<Long, Double>)usageStats.getUsage(); 
     516        private Map<Long, Double> createResourceLoadData(ResourceUsageStats usageStats, List<ResStat> resStats) { 
     517 
     518                TreeMap<Long, Double> ganttData = (TreeMap<Long, Double>)usageStats.getHistory(); 
    530519                for (ResStat resStat : resStats) { 
    531520                         
     
    575564         
    576565         
    577         private ResourceEnergyStats gatherResourceEnergyStats(ComputingResource resource) { 
     566        private ResourcePowerStats gatherResourcePowerConsumptionStats(ComputingResource resource) { 
    578567                double power = 0; 
    579                 ResourceEnergyStats resEnergyUsage = new ResourceEnergyStats(resource.getName(), resource.getType(), "resourceEnergyStats"); 
    580                 Map<Long, Double> usage = resEnergyUsage.getEnergy(); 
     568                ResourcePowerStats resEnergyUsage = new ResourcePowerStats(resource.getName(), resource.getType(), "resourcePowerConsumptionStats"); 
     569                Map<Long, Double> usage = resEnergyUsage.getHistory(); 
    581570                 
    582571                ExtensionList extensionList = resource.getExtensionList(); 
     
    613602 
    614603                ResourceAirFlowStats resAirFlow = new ResourceAirFlowStats(resource.getName(), resource.getType(), "resourceAirFlowStats"); 
    615                 Map<Long, Double> airFlow = resAirFlow.getAirFlow(); 
     604                Map<Long, Double> airFlow = resAirFlow.getHistory(); 
    616605                 
    617606                ExtensionList extensionList = resource.getExtensionList(); 
     
    625614                                        if(airFlowHistory.size() == 0) 
    626615                                                break; 
    627                                         long lastTime = DateTimeUtilsExt.getOffsetTime().getTimeInMillis(); 
    628616                                        long endSimulationTime = DateTimeUtilsExt.currentTimeMillis(); 
    629                                         double lastAirFlow = 0; 
    630617                                        airFlowHistory.add(new AirFlowValue(endSimulationTime, ee.getAirFlowProfile().getAirThroughputHistory().get(ee.getAirFlowProfile().getAirThroughputHistory().size()-1).getValue())); 
    631618                                        for(AirFlowValue af:airFlowHistory){ 
    632619                                                airFlow.put(af.getTimestamp(), af.getValue()); 
    633  
    634                                                 lastAirFlow = af.getValue(); 
    635                                                 lastTime = af.getTimestamp(); 
    636620                                        } 
    637621                                } 
     
    641625        } 
    642626         
    643         private void createResourceEnergyGanttDiagram(ResourceEnergyStats powerUsage) { 
    644  
    645                 XYDataset dataset = createResourceEnergyGanttDataSet(powerUsage, 
     627        private void createResourceLoadDiagram(ResourceUsageStats resLoadStats) { 
     628 
     629                XYDataset dataset = createResourceChartDataSet(resLoadStats, 
    646630                                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                         resourcePowerUsageDiagrams.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); 
    653637                } 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, 
    662645                                startSimulationTime, endSimulationTime); 
    663646                 
    664                 List<XYDataset> airFlowDiagram = resourceAirFlowDiagrams.get(airFlow.getResourceType()); 
    665                 if(airFlowDiagram == null){ 
    666                         airFlowDiagram = new ArrayList<XYDataset>(); 
    667                         airFlowDiagram.add(dataset); 
    668                         resourceAirFlowDiagrams.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); 
    669652                } 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); 
    679676                XYSeriesCollection dataset = new XYSeriesCollection(); 
    680                 XYSeries data = new XYSeries(energyUsage.getResourceName(), false, true); 
     677                XYSeries data = new XYSeries(dynamicStats.getResourceName(), false, true); 
    681678                //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); 
    684681                        data.add(key, val); 
    685682                } 
     
    689686        } 
    690687 
    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; 
    728697        } 
    729698 
    730699        private boolean saveResourceGanttDiagrams() { 
    731                 JFreeChart resourceDiagram = null; 
    732                 JFreeChart peDiagram = null; 
    733                 JFreeChart resourceEnergyDiagram = null; 
    734                 JFreeChart resourceAirFlowDiagram = null; 
     700 
    735701                if (!generateDiagrams) 
    736702                        return false; 
     
    745711                                + "\" at " + Calendar.getInstance().getTime().toString()); 
    746712 
    747                  
     713                JFreeChart peDiagram = null; 
    748714                if (configuration.creatediagrams_processors) { 
    749                         peDiagram = getPeGanttDiagram(chartName, subtitle, 
     715                        peDiagram = getPEGanttDiagram(chartName, subtitle, 
    750716                                        simulationTime); 
    751717                        if (!saveCategoryChart(peDiagram, fileName + "Gantt", 
     
    754720                } 
    755721 
     722                JFreeChart resourceLoadDiagram = null; 
    756723                if (configuration.creatediagrams_resources) { 
     724                        String axisName = "UTILIZATION [%]"; 
    757725                        for(ResourceType resType: resourceLoadDiagrams.keySet()){ 
    758                                 resourceDiagram = getResourcesLoadDiagram(resType, chartName, subtitle, 
    759                                                 simulationTime); 
    760                                 if (!saveXYPlotChart(resourceDiagram, fileName + "Resources Load - "+resType)) 
     726                                resourceLoadDiagram = getResourceDynamicDiagram(resourceLoadDiagrams.get(resType), simulationTime, chartName, 
     727                                                subtitle, axisName); 
     728                                if (!saveXYPlotChart(resourceLoadDiagram, fileName + "Resources Load - "+resType)) 
    761729                                        return false; 
    762730                        } 
    763  
    764                 } 
     731                } 
     732                 
     733                JFreeChart resourceEnergyDiagram = null; 
    765734                if (configuration.creatediagrams_energyusage) { 
     735                        String axisName = "POWER [W]"; 
    766736                        for(ResourceType resType: resourcePowerUsageDiagrams.keySet()){ 
    767                                 resourceEnergyDiagram = getResourcesEnergyDiagram(resType, chartName, 
    768                                                 subtitle, simulationTime); 
     737                                resourceEnergyDiagram = getResourceDynamicDiagram(resourcePowerUsageDiagrams.get(resType), simulationTime, chartName, 
     738                                                subtitle, axisName); 
    769739                                if (!saveXYPlotChart(resourceEnergyDiagram, fileName + "Energy - "+resType)) 
    770740                                        return false; 
     
    772742                } 
    773743                 
    774                  
     744                JFreeChart resourceAirFlowDiagram = null; 
    775745                if (configuration.creatediagrams_airflow) { 
     746                        String axisName = "AIR FLOW [m^3/min]"; 
    776747                        for(ResourceType resType: resourceAirFlowDiagrams.keySet()){ 
    777                                 resourceAirFlowDiagram = getResourcesAirFlowDiagram(resType, chartName, 
    778                                                 subtitle, simulationTime); 
     748                                resourceAirFlowDiagram = getResourceDynamicDiagram(resourceAirFlowDiagrams.get(resType), simulationTime, chartName, 
     749                                                subtitle, axisName); 
    779750                                if (!saveXYPlotChart(resourceAirFlowDiagram, fileName + "AirThroughput - "+resType)) 
    780751                                        return false; 
     
    784755        } 
    785756         
    786         private JFreeChart getResourcesLoadDiagram(ResourceType resType, String chartName, Title subtitle, 
     757        private JFreeChart getPEGanttDiagram(String chartName, Title subtitle, 
    787758                        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) { 
    789774                boolean urls = false; 
    790775                boolean tooltip = true; 
     
    794779                JFreeChart chart = null; 
    795780 
    796                 List<XYDataset> loadDiagram = resourceLoadDiagrams.get(resType); 
    797                 for (XYDataset dataset : loadDiagram) { 
     781                for (XYDataset dataset : diagramData) { 
    798782                        JFreeChart tChart = ChartFactory.createXYStepAreaChart("", "", 
    799                                 null, dataset, PlotOrientation.VERTICAL, legend, tooltip, 
    800                                 urls); 
     783                                null, dataset, PlotOrientation.VERTICAL, legend, tooltip, urls); 
    801784                        XYPlot tPlot = tChart.getXYPlot(); 
    802                         NumberAxis yAxis = new NumberAxis(cpu); 
     785                        NumberAxis yAxis = new NumberAxis(axisName); 
    803786                        yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); 
    804787                        tPlot.setRangeAxis(yAxis); 
     
    813796                return chart; 
    814797        } 
    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          
    894798         
    895799        private boolean saveXYPlotChart(JFreeChart c, String fileName) { 
     
    932836                for(String peName: basicResStats.keySet()){ 
    933837                        TimetableEventSource pe = new TimetableEventSource(peName); 
    934                         ganttDiagramPeTimetable.addEventSource(pe); 
     838                        ganttDiagramTimetable.addEventSource(pe); 
    935839                        peGanttMap.put(peName, pe); 
    936840                        for(ResStat resStat: basicResStats.get(peName)){ 
     
    948852                                        task = new TimetableEventGroup(resStat.getTaskID()); 
    949853                                        taskGanttMap.put(resStat.getTaskID(), task); 
    950                                         ganttDiagramPeTimetable.addEventGroup(task); 
    951                                 } 
    952                                 ganttDiagramPeTimetable.addEvent(pe, task, 
     854                                        ganttDiagramTimetable.addEventGroup(task); 
     855                                } 
     856                                ganttDiagramTimetable.addEvent(pe, task, 
    953857                                                new FixedMillisecond(startDate), new FixedMillisecond(endDate)); 
    954858                        } 
     
    956860        } 
    957861 
    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 
    987863 
    988864        private void createAccumulatedResourceSimulationStatistic() { 
     
    1014890        } 
    1015891         
    1016         private  Double calculateResourceLoad(ComputingResource resource, HashMap<String, Double> peLoad ){ 
     892        private  Double calculateResourceLoad(ComputingResource resource, Map<String, Double> peLoad ){ 
    1017893                int peCnt = 0; 
    1018894                double sum = 0; 
     
    1033909                return sum/peCnt; 
    1034910        } 
    1035          
    1036         private double calculateEnergyLoad(ResourceEnergyStats resEnergyStats ){ 
    1037                 double meanEnergyUsage = 0; 
     911 
     912         
     913        private double calculateMeanValue(ResourceDynamicStats resDynamicStats ){ 
     914                double meanValue = 0; 
    1038915                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()) { 
    1042920                         
    1043921                        if (time != 0) { 
    1044                                 meanEnergyUsage += (usage * (key - time)) 
    1045                                                 / (endSimulationTime - startSimulationTime); 
    1046  
     922                                meanValue += (value * (key - time)) / (endSimulationTime - startSimulationTime); 
    1047923                                time = key; 
    1048924                        } else { 
    1049925                                time = key; 
    1050926                        } 
    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         
    1098937         
    1099938 
     
    11941033        } 
    11951034 
     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         
    11961049        private TaskStats createTaskStats(Executable task) { 
    11971050                TaskStats taskStats = new TaskStats(task, startSimulationTime); 
     
    14251278 
    14261279                public int compare(JobInterface<?> o1, JobInterface<?> o2) { 
    1427  
    14281280                        Integer o1int; 
    14291281                        Integer o2int; 
     
    14351287                                return o1.getId().compareTo(o2.getId()); 
    14361288                        } 
    1437  
    14381289                } 
    14391290        } 
     
    14811332class ResStat{ 
    14821333         
    1483          
    14841334        public long getStartDate() { 
    14851335                return startDate; 
Note: See TracChangeset for help on using the changeset viewer.