Skip to content

Commit

Permalink
Updates PowerModel documentation and performs small refactoring.
Browse files Browse the repository at this point in the history
Signed-off-by: Manoel Campos <manoelcampos@gmail.com>
  • Loading branch information
manoelcampos committed Nov 26, 2018
1 parent 981b8df commit 080afa0
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public class PowerModelLinear extends PowerModelSimple {
* @param staticPowerPercent the static power usage percentage between 0 and 1.
*/
public PowerModelLinear(final double maxPower, final double staticPowerPercent) {
/** Calls the super constructor passing a {@link #powerFunction}
* that indicates the base power consumption is linear to CPU utilization.*/
super(maxPower, staticPowerPercent, utilizationPercent -> utilizationPercent);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,16 @@ public class PowerModelSimple extends PowerModelAbstract {
*/
private static final double ONE_HUNDRED = 100.0;

private final UnaryOperator<Double> powerIncrementFunction;
/**
* A function defining how the power consumption is computed based on the CPU utilization.
* When called, this function receives the utilization percentage in scale from [0 to 100]
* and must return the base power consumption for that CPU utilization.
* The function is only accountable to compute the base energy consumption
* because the total energy consumption depends on other factors such as
* the {@link #getStaticPower() static power} consumed by the Host,
* independent of its CPU usage.
*/
private final UnaryOperator<Double> powerFunction;

/**
* @see #getMaxPower()
Expand All @@ -37,21 +46,23 @@ public class PowerModelSimple extends PowerModelAbstract {
/**
* Instantiates a PowerModelSimple.
*
* @param maxPower the max power that can be consumed in Watt-Second (Ws).
* @param staticPowerPercent the static power usage percentage between 0 and 1.
* @param powerIncrementFunction a function that defines how the power consumption increases along the time.
* This function receives the utilization percentage in scale from 0 to 100
* and returns a factor representing how the power consumption will
* increase for the given utilization percentage.
* The function return is again a percentage value between [0 and 1].
* @param maxPower the max power that can be consumed in Watt-Second (Ws).
* @param staticPowerPercent the static power usage percentage between [0 and 1].
* @param powerFunction A function defining how the power consumption is computed based on the CPU utilization.
* When called, this function receives the utilization percentage in scale from [0 to 100]
* and must return the base power consumption for that CPU utilization.
* The function is only accountable to compute the base energy consumption
* because the total energy consumption depends on other factors such as
* the {@link #getStaticPower() static power} consumed by the Host,
* independent of its CPU usage.
*/
public PowerModelSimple(
final double maxPower,
final double staticPowerPercent,
final UnaryOperator<Double> powerIncrementFunction)
final UnaryOperator<Double> powerFunction)
{
super();
this.powerIncrementFunction = Objects.requireNonNull(powerIncrementFunction);
this.powerFunction = Objects.requireNonNull(powerFunction);
setMaxPower(maxPower);
setStaticPowerPercent(staticPowerPercent);
}
Expand Down Expand Up @@ -114,11 +125,11 @@ public final double getStaticPower() {
* @return the power consumption constant in Watt-Second (Ws)
*/
protected double getConstant() {
return (maxPower - getStaticPower()) / powerIncrementFunction.apply(ONE_HUNDRED);
return (maxPower - getStaticPower()) / powerFunction.apply(ONE_HUNDRED);
}

@Override
protected double getPowerInternal(final double utilization) throws IllegalArgumentException {
return getStaticPower() + getConstant() * powerIncrementFunction.apply(utilization* ONE_HUNDRED);
return getStaticPower() + getConstant() * powerFunction.apply(utilization*ONE_HUNDRED);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
/**
* Computes the monetary cost to run a given VM,
* including the {@link #getTotalCost() total cost}
* and individual resource cost, namely
* and individual resource cost, namely:
* the processing power, bandwidth, memory and storage cost.
*
* @author raysaoliveira
Expand Down

0 comments on commit 080afa0

Please sign in to comment.