source: DCWoRMS/trunk/src/test/ariel/CPUFreqScalingExecTimeEstimationPlugin.java @ 509

Revision 509, 1.4 KB checked in by wojtekp, 13 years ago (diff)
  • Property svn:mime-type set to text/plain
Line 
1package test.ariel;
2
3import java.util.Map;
4
5import schedframe.events.scheduling.SchedulingEvent;
6import schedframe.resources.computing.Processor;
7import schedframe.resources.units.PEUnit;
8import schedframe.resources.units.ProcessingElements;
9import schedframe.resources.units.ResourceUnit;
10import schedframe.resources.units.ResourceUnitName;
11import schedframe.resources.units.StandardResourceUnitName;
12import dcworms.schedframe.scheduling.ExecTask;
13import example.timeestimation.BaseTimeEstimationPlugin;
14
15public class CPUFreqScalingExecTimeEstimationPlugin extends BaseTimeEstimationPlugin{
16
17        public double execTimeEstimation(SchedulingEvent event, ExecTask task,
18                        Map<ResourceUnitName, ResourceUnit> allocatedResources,
19                        double completionPercentage) {
20
21                PEUnit peUnit = (PEUnit) allocatedResources.get(StandardResourceUnitName.PE);
22
23                double speed;
24                if(peUnit instanceof ProcessingElements){
25                        ProcessingElements pe = (ProcessingElements)peUnit;
26                        Processor cpu = (Processor)pe.get(0);
27                        speed = cpu.getPowerInterface().getPState().getFrequency()/1000;
28                }
29                else
30                        speed = peUnit.getSpeed();
31               
32                int cnt = peUnit.getUsedAmount();
33
34                double remainingLength =  task.getLength() * (1 - completionPercentage/100);
35
36                double execTime = (remainingLength / (cnt * speed));
37
38                if (Double.compare(execTime, 0.001) < 0) {
39                        execTime = 0.001;
40                }
41
42                execTime = Math.ceil(execTime);
43                return execTime;
44        }
45
46}
Note: See TracBrowser for help on using the repository browser.