Package org.cloudbus.cloudsim.vms
Class AbstractResourceStats<T extends AbstractMachine>
java.lang.Object
org.cloudbus.cloudsim.vms.AbstractResourceStats<T>
- Type Parameters:
T
- The kind of machine to collect resource utilization statistics
- Direct Known Subclasses:
HostResourceStats
,VmResourceStats
public abstract class AbstractResourceStats<T extends AbstractMachine> extends Object
Computes statistics about
Resource
utilization for a given machine (VM or Host).
Such a resource can be, for instance, CPU, RAM or BW.- Since:
- CloudSim Plus 6.1.0
- Author:
- Manoel Campos da Silva Filho
-
Constructor Summary
Constructors Constructor Description AbstractResourceStats(T machine, Function<T,Double> resourceUtilizationFunction)
Creates a ResourceStats to collect resource utilization statistics. -
Method Summary
Modifier and Type Method Description boolean
add(double time)
Collects the current resource utilization percentage (in scale from 0 to 1) for the given time to the statistics.double
count()
Gets the number of collected resource utilization samples.protected T
getMachine()
double
getMax()
Gets the maximum resource utilization percentage (from 0 to 1).double
getMean()
Gets the average resource utilization percentage (from 0 to 1).double
getMin()
Gets the minimum resource utilization percentage (from 0 to 1).protected double
getPreviousTime()
Gets the previous time that resource statistics were computed.double
getStandardDeviation()
Gets the Standard Deviation of resource utilization percentage (from 0 to 1).double
getVariance()
Gets the (sample) variance of resource utilization percentage (from 0 to 1).protected boolean
isElapsedTimeSmall(double time)
boolean
isEmpty()
Indicates if no resource utilization sample was collected.protected boolean
isNotEntireSecondElapsed(double time)
protected boolean
isNotTimeToAddHistory(double time)
Checks if it isn't time to add a value to the utilization history.
-
Constructor Details
-
AbstractResourceStats
Creates a ResourceStats to collect resource utilization statistics.- Parameters:
machine
- the machine where the statistics will be collected (which can be a Vm or Host)resourceUtilizationFunction
- aFunction
that receives a Machine and returns the current resource utilization for that machine
-
-
Method Details
-
add
public boolean add(double time)Collects the current resource utilization percentage (in scale from 0 to 1) for the given time to the statistics.- Parameters:
time
- current simulation time
-
getMin
public double getMin()Gets the minimum resource utilization percentage (from 0 to 1).- Returns:
-
getMax
public double getMax()Gets the maximum resource utilization percentage (from 0 to 1).- Returns:
-
getMean
public double getMean()Gets the average resource utilization percentage (from 0 to 1).- Returns:
-
getStandardDeviation
public double getStandardDeviation()Gets the Standard Deviation of resource utilization percentage (from 0 to 1).- Returns:
-
getVariance
public double getVariance()Gets the (sample) variance of resource utilization percentage (from 0 to 1).- Returns:
-
count
public double count()Gets the number of collected resource utilization samples.- Returns:
-
isEmpty
public boolean isEmpty()Indicates if no resource utilization sample was collected.- Returns:
-
isNotTimeToAddHistory
protected final boolean isNotTimeToAddHistory(double time)Checks if it isn't time to add a value to the utilization history. The utilization history is not updated in any one of the following conditions is met:- the simulation clock was not changed yet;
- the time passed is smaller than one second and the VM is not idle;
- the floor time is equal to the previous time and VM is not idle.
If the time is smaller than one second and the VM became idle, the history will be added so that we know what is the resource utilization when the VM became idle. This way, we can see clearly in the history when the VM was busy and when it became idle.
If the floor time is equal to the previous time and VM is not idle, that means not even a second has passed. This way, that utilization will not be stored.
- Parameters:
time
- the current simulation time- Returns:
- true if it's time to add utilization history, false otherwise
-
isElapsedTimeSmall
protected final boolean isElapsedTimeSmall(double time) -
isNotEntireSecondElapsed
protected final boolean isNotEntireSecondElapsed(double time) -
getMachine
-
getPreviousTime
protected double getPreviousTime()Gets the previous time that resource statistics were computed.- Returns:
-