Class ResourceStats<T extends Machine>
java.lang.Object
org.cloudsimplus.vms.ResourceStats<T>
- Type Parameters:
T- The kind of machine to collect resource utilization statistics, such asVmorHost
- Direct Known Subclasses:
HostResourceStats,VmResourceStats
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedResourceStats(T machine, @NonNull Function<T, Double> resourceUtilizationFunction) Creates a ResourceStats to collect resource utilization statistics. -
Method Summary
Modifier and TypeMethodDescriptionbooleanadd(double time) Collects the current resource utilization percentage (in scale from 0 to 1) for the given time to the statistics.doublecount()protected TdoublegetMax()doublegetMean()doublegetMin()protected doubledoubledoubleprotected final booleanisElapsedTimeSmall(double time) booleanisEmpty()protected final booleanisNotEntireSecondElapsed(double time) protected final booleanisNotTimeToAddHistory(double time) Returns true if it's time to add utilization history, false otherwise.
-
Constructor Details
-
ResourceStats
protected ResourceStats(@NonNull T machine, @NonNull @NonNull Function<T, Double> resourceUtilizationFunction) Creates a ResourceStats to collect resource utilization statistics.- Parameters:
machine- the machine where the statistics will be collected from (which can be a Vm or Host)resourceUtilizationFunction- aFunctionthat 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 (in seconds)- Returns:
- true if data was collected, false otherwise (meaning it's not time to collect data).
-
getMin
public double getMin()- Returns:
- the minimum resource utilization percentage (from 0 to 1).
-
getMax
public double getMax()- Returns:
- the maximum resource utilization percentage (from 0 to 1).
-
getMean
public double getMean()- Returns:
- the average resource utilization percentage (from 0 to 1).
-
getStandardDeviation
public double getStandardDeviation()- Returns:
- the Standard Deviation of resource utilization percentage (from 0 to 1).
-
getVariance
public double getVariance()- Returns:
- the (sample) variance of resource utilization percentage (from 0 to 1).
-
count
public double count()- Returns:
- the number of collected resource utilization samples.
-
isEmpty
public boolean isEmpty()- Returns:
- true if no resource utilization sample was collected, false otherwise.
-
isNotTimeToAddHistory
protected final boolean isNotTimeToAddHistory(double time) Returns true if it's time to add utilization history, false otherwise. The utilization history is not updated if 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 machine is not idle.
- The floor time is equal to the previous time, and the machine is not idle.
If the time is smaller than one second and the machine became idle, the history will be added so that we know what the resource utilization was when the VM became idle. This way, we can see clearly in the history when the machine was busy and when it became idle.
If the floor time is equal to the previous time and the machine is not idle, that means not even a second has passed. Therefore, that utilization value 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()- Returns:
- the previous time that resource statistics were computed.
-