package test.ariel; import java.util.Map; import schedframe.events.scheduling.SchedulingEvent; import schedframe.resources.computing.Processor; import schedframe.resources.units.PEUnit; import schedframe.resources.units.ProcessingElements; import schedframe.resources.units.ResourceUnit; import schedframe.resources.units.ResourceUnitName; import schedframe.resources.units.StandardResourceUnitName; import dcworms.schedframe.scheduling.ExecTask; import example.timeestimation.BaseTimeEstimationPlugin; public class CPUFreqScalingExecTimeEstimationPlugin extends BaseTimeEstimationPlugin{ public double execTimeEstimation(SchedulingEvent event, ExecTask task, Map allocatedResources, double completionPercentage) { PEUnit peUnit = (PEUnit) allocatedResources.get(StandardResourceUnitName.PE); double speed; if(peUnit instanceof ProcessingElements){ ProcessingElements pe = (ProcessingElements)peUnit; Processor cpu = (Processor)pe.get(0); speed = cpu.getPowerInterface().getPState().getFrequency()/1000; } else speed = peUnit.getSpeed(); int cnt = peUnit.getUsedAmount(); double remainingLength = task.getLength() * (1 - completionPercentage/100); double execTime = (remainingLength / (cnt * speed)); if (Double.compare(execTime, 0.001) < 0) { execTime = 0.001; } execTime = Math.ceil(execTime); return execTime; } }