cloudsim-plus-master/cloudsim-plus-master/cloudsim-plus-examples/src/main/java/org/cloudbus/cloudsim/examples/power/util/Helper.java
public void printResults(final PowerDatacenter datacenter, final List<Vm> vmList, final double lastClock) {
        Log.enable();
        final List<HostSimple> hosts = datacenter.getHostList();
        final Map<String, Double> slaMetrics = getSlaMetrics(vmList);

        final double averageSlaViolationPercent = slaMetrics.get(SLA_METRIC_AVERAGE_PERCENT);
        final double percentSlaDegradationDueMigration = slaMetrics.get(SLA_METRIC_UNDERALLOCATED_MIGRATION);
        final double percentSlaViolationTimeForActiveHosts = getSlaViolationTimePercentageForHosts(hosts);
        //@todo It's not clear the difference between the two variables below
        final double overallSlaViolationPercent = slaMetrics.get(SLA_METRIC_OVERALL_PERCENT);
        final double slaViolationsPercent = percentSlaViolationTimeForActiveHosts * percentSlaDegradationDueMigration;

        final List<Double> timeBeforeHostShutdown = getTimesBeforeHostShutdown(hosts);
        final double meanTimeBeforeHostShutdown = timeBeforeHostShutdown.isEmpty() ? Double.NaN : MathUtil.mean(timeBeforeHostShutdown);
        final double stDevTimeBeforeHostShutdown = timeBeforeHostShutdown.isEmpty() ? Double.NaN : MathUtil.stDev(timeBeforeHostShutdown);

        final List<Double> timeBeforeVmMigration = getTimesBeforeVmMigration(vmList);
        final double meanTimeBeforeVmMigration = timeBeforeVmMigration.isEmpty() ? Double.NaN : MathUtil.mean(timeBeforeVmMigration);
        final double stDevTimeBeforeVmMigration = timeBeforeVmMigration.isEmpty() ? Double.NaN : MathUtil.stDev(timeBeforeVmMigration);

        createOutputFoldersIfCsvOutput(outputInCsv, outputFolder);
        Log.enable();
        Log.printLine();
        final String delimiter = ",";
        this.buffer = new StringBuilder();
        addStringToBuffer("Experiment name", "%s", experimentName);
        addStringToBuffer("Number of Hosts", "%d", hosts.size());
        addStringToBuffer("Number of VMs", "%d", vmList.size());
        addStringToBuffer("Total simulation time", "%.2f", lastClock, "sec ("+lastClock/60+" min)");
        addStringToBuffer("Energy consumption", "%.2f", datacenter.getPowerInKWattsHour(), "kWh");
        addStringToBuffer("Number of VM migrations", "%d", datacenter.getMigrationCount());

        addStringToBuffer("SLA violations", "%.5f%%", slaViolationsPercent * 100);
        addStringToBuffer("SLA performance degradation due to migration", "%.5f%%", percentSlaDegradationDueMigration * 100);
        addStringToBuffer("SLA violation time for active hosts", "%.5f%%", percentSlaViolationTimeForActiveHosts * 100);
        addStringToBuffer("Overall SLA violation", "%.5f%%", overallSlaViolationPercent * 100);
        addStringToBuffer("Average SLA violation", "%.5f%%", averageSlaViolationPercent * 100);

        addStringToBuffer("Number of host shutdowns", "%d", timeBeforeHostShutdown.size());
        addStringToBuffer("Mean time before a host shutdown", "%.2f", meanTimeBeforeHostShutdown, "sec");
        addStringToBuffer("StDev time before a host shutdown", "%.2f", stDevTimeBeforeHostShutdown, "sec");
        addStringToBuffer("Mean time before a VM migration", "%.2f", meanTimeBeforeVmMigration, "sec");
        addStringToBuffer("StDev time before a VM migration", "%.2f", stDevTimeBeforeVmMigration, "sec");

        PowerVmAllocationPolicyMigration vap = getPowerVmAllocationPolicy(datacenter);
        this.buffer.append("\n");

        if (outputInCsv) {
            if (!PowerVmAllocationPolicyMigration.NULL.equals(vap)) {
                writeMetricHistoryToFile(hosts, vap, outputFolder + "/metrics/" + experimentName + "_metric");
            }

            writeBufferToFile(outputFolder + "/stats/" + experimentName + "_stats.csv");
            writeDataToFile(timeBeforeHostShutdown, outputFolder + "/time_before_host_shutdown/"
                + experimentName + "_time_before_host_shutdown.csv");
            writeDataToFile(timeBeforeVmMigration, outputFolder + "/time_before_vm_migration/"
                + experimentName + "_time_before_vm_migration.csv");
        } else Log.print(buffer.toString());
        this.buffer = null;

        Log.printLine();
        Log.disable();
    }
/**
     * Prints the results.
     *
     * @param datacenter the Datacenter
     * @param vmList     the List of VMs to get results from
     * @param lastClock  the clock at the end of the simulation
     */
Prints the results.
@param datacenter the Datacenter
@param vmList     the List of VMs to get results from
@param lastClock  the clock at the end of the simulation
Prints the results . @param datacenter the Datacenter @param vmList the List of VMs to get results from @param lastClock the clock at the end of the simulation
public void printResults(final PowerDatacenter datacenter, final List<Vm> vmList, final double lastClock) {
        Log.enable();
        final List<HostSimple> hosts = datacenter.getHostList();
        final Map<String, Double> slaMetrics = getSlaMetrics(vmList);
        final double averageSlaViolationPercent = slaMetrics.get(SLA_METRIC_AVERAGE_PERCENT);
        final double percentSlaDegradationDueMigration = slaMetrics.get(SLA_METRIC_UNDERALLOCATED_MIGRATION);
        final double percentSlaViolationTimeForActiveHosts = getSlaViolationTimePercentageForHosts(hosts);
        final double overallSlaViolationPercent = slaMetrics.get(SLA_METRIC_OVERALL_PERCENT);
        final double slaViolationsPercent = percentSlaViolationTimeForActiveHosts * percentSlaDegradationDueMigration;
        final List<Double> timeBeforeHostShutdown = getTimesBeforeHostShutdown(hosts);
        final double meanTimeBeforeHostShutdown = timeBeforeHostShutdown.isEmpty() ? Double.NaN : MathUtil.mean(timeBeforeHostShutdown);
        final double stDevTimeBeforeHostShutdown = timeBeforeHostShutdown.isEmpty() ? Double.NaN : MathUtil.stDev(timeBeforeHostShutdown);
        final List<Double> timeBeforeVmMigration = getTimesBeforeVmMigration(vmList);
        final double meanTimeBeforeVmMigration = timeBeforeVmMigration.isEmpty() ? Double.NaN : MathUtil.mean(timeBeforeVmMigration);
        final double stDevTimeBeforeVmMigration = timeBeforeVmMigration.isEmpty() ? Double.NaN : MathUtil.stDev(timeBeforeVmMigration);
        createOutputFoldersIfCsvOutput(outputInCsv, outputFolder);
        Log.enable();
        Log.printLine();
        final String delimiter = ",";
        this.buffer = new StringBuilder();
        addStringToBuffer("Experiment name", "%s", experimentName);
        addStringToBuffer("Number of Hosts", "%d", hosts.size());
        addStringToBuffer("Number of VMs", "%d", vmList.size());
        addStringToBuffer("Total simulation time", "%.2f", lastClock, "sec ("+lastClock/60+" min)");
        addStringToBuffer("Energy consumption", "%.2f", datacenter.getPowerInKWattsHour(), "kWh");
        addStringToBuffer("Number of VM migrations", "%d", datacenter.getMigrationCount());
        addStringToBuffer("SLA violations", "%.5f%%", slaViolationsPercent * 100);
        addStringToBuffer("SLA performance degradation due to migration", "%.5f%%", percentSlaDegradationDueMigration * 100);
        addStringToBuffer("SLA violation time for active hosts", "%.5f%%", percentSlaViolationTimeForActiveHosts * 100);
        addStringToBuffer("Overall SLA violation", "%.5f%%", overallSlaViolationPercent * 100);
        addStringToBuffer("Average SLA violation", "%.5f%%", averageSlaViolationPercent * 100);
        addStringToBuffer("Number of host shutdowns", "%d", timeBeforeHostShutdown.size());
        addStringToBuffer("Mean time before a host shutdown", "%.2f", meanTimeBeforeHostShutdown, "sec");
        addStringToBuffer("StDev time before a host shutdown", "%.2f", stDevTimeBeforeHostShutdown, "sec");
        addStringToBuffer("Mean time before a VM migration", "%.2f", meanTimeBeforeVmMigration, "sec");
        addStringToBuffer("StDev time before a VM migration", "%.2f", stDevTimeBeforeVmMigration, "sec");
        PowerVmAllocationPolicyMigration vap = getPowerVmAllocationPolicy(datacenter);
        this.buffer.append("\n");
        if (outputInCsv) {
            if (!PowerVmAllocationPolicyMigration.NULL.equals(vap)) {
                writeMetricHistoryToFile(hosts, vap, outputFolder + "/metrics/" + experimentName + "_metric");
            }
            writeBufferToFile(outputFolder + "/stats/" + experimentName + "_stats.csv");
            writeDataToFile(timeBeforeHostShutdown, outputFolder + "/time_before_host_shutdown/"
                + experimentName + "_time_before_host_shutdown.csv");
            writeDataToFile(timeBeforeVmMigration, outputFolder + "/time_before_vm_migration/"
                + experimentName + "_time_before_vm_migration.csv");
        } else Log.print(buffer.toString());
        this.buffer = null;
        Log.printLine();
        Log.disable();
    }
public void printResults ( final PowerDatacenter datacenter , final List < Vm > vmList , final double lastClock ) { Log . enable ( ) ; final List < HostSimple > hosts = datacenter . getHostList ( ) ; final Map < String , Double > slaMetrics = getSlaMetrics ( vmList ) ; final double averageSlaViolationPercent = slaMetrics . get ( SLA_METRIC_AVERAGE_PERCENT ) ; final double percentSlaDegradationDueMigration = slaMetrics . get ( SLA_METRIC_UNDERALLOCATED_MIGRATION ) ; final double percentSlaViolationTimeForActiveHosts = getSlaViolationTimePercentageForHosts ( hosts ) ; final double overallSlaViolationPercent = slaMetrics . get ( SLA_METRIC_OVERALL_PERCENT ) ; final double slaViolationsPercent = percentSlaViolationTimeForActiveHosts * percentSlaDegradationDueMigration ; final List < Double > timeBeforeHostShutdown = getTimesBeforeHostShutdown ( hosts ) ; final double meanTimeBeforeHostShutdown = timeBeforeHostShutdown . isEmpty ( ) ? Double . NaN : MathUtil . mean ( timeBeforeHostShutdown ) ; final double stDevTimeBeforeHostShutdown = timeBeforeHostShutdown . isEmpty ( ) ? Double . NaN : MathUtil . stDev ( timeBeforeHostShutdown ) ; final List < Double > timeBeforeVmMigration = getTimesBeforeVmMigration ( vmList ) ; final double meanTimeBeforeVmMigration = timeBeforeVmMigration . isEmpty ( ) ? Double . NaN : MathUtil . mean ( timeBeforeVmMigration ) ; final double stDevTimeBeforeVmMigration = timeBeforeVmMigration . isEmpty ( ) ? Double . NaN : MathUtil . stDev ( timeBeforeVmMigration ) ; createOutputFoldersIfCsvOutput ( outputInCsv , outputFolder ) ; Log . enable ( ) ; Log . printLine ( ) ; final String delimiter = "," ; this . buffer = new StringBuilder ( ) ; addStringToBuffer ( "Experiment name" , "%s" , experimentName ) ; addStringToBuffer ( "Number of Hosts" , "%d" , hosts . size ( ) ) ; addStringToBuffer ( "Number of VMs" , "%d" , vmList . size ( ) ) ; addStringToBuffer ( "Total simulation time" , "%.2f" , lastClock , "sec (" + lastClock / 60 + " min)" ) ; addStringToBuffer ( "Energy consumption" , "%.2f" , datacenter . getPowerInKWattsHour ( ) , "kWh" ) ; addStringToBuffer ( "Number of VM migrations" , "%d" , datacenter . getMigrationCount ( ) ) ; addStringToBuffer ( "SLA violations" , "%.5f%%" , slaViolationsPercent * 100 ) ; addStringToBuffer ( "SLA performance degradation due to migration" , "%.5f%%" , percentSlaDegradationDueMigration * 100 ) ; addStringToBuffer ( "SLA violation time for active hosts" , "%.5f%%" , percentSlaViolationTimeForActiveHosts * 100 ) ; addStringToBuffer ( "Overall SLA violation" , "%.5f%%" , overallSlaViolationPercent * 100 ) ; addStringToBuffer ( "Average SLA violation" , "%.5f%%" , averageSlaViolationPercent * 100 ) ; addStringToBuffer ( "Number of host shutdowns" , "%d" , timeBeforeHostShutdown . size ( ) ) ; addStringToBuffer ( "Mean time before a host shutdown" , "%.2f" , meanTimeBeforeHostShutdown , "sec" ) ; addStringToBuffer ( "StDev time before a host shutdown" , "%.2f" , stDevTimeBeforeHostShutdown , "sec" ) ; addStringToBuffer ( "Mean time before a VM migration" , "%.2f" , meanTimeBeforeVmMigration , "sec" ) ; addStringToBuffer ( "StDev time before a VM migration" , "%.2f" , stDevTimeBeforeVmMigration , "sec" ) ; PowerVmAllocationPolicyMigration vap = getPowerVmAllocationPolicy ( datacenter ) ; this . buffer . append ( "\n" ) ; if ( outputInCsv ) { if ( ! PowerVmAllocationPolicyMigration . NULL . equals ( vap ) ) { writeMetricHistoryToFile ( hosts , vap , outputFolder + "/metrics/" + experimentName + "_metric" ) ; } writeBufferToFile ( outputFolder + "/stats/" + experimentName + "_stats.csv" ) ; writeDataToFile ( timeBeforeHostShutdown , outputFolder + "/time_before_host_shutdown/" + experimentName + "_time_before_host_shutdown.csv" ) ; writeDataToFile ( timeBeforeVmMigration , outputFolder + "/time_before_vm_migration/" + experimentName + "_time_before_vm_migration.csv" ) ; } else Log . print ( buffer . toString ( ) ) ; this . buffer = null ; Log . printLine ( ) ; Log . disable ( ) ; }
Prints the results.
Prints the results .
//@todo It's not clear the difference between the two variables below