1 | package de.uka.ipd.sdq.measurement.strategies.activeresource.cpu; |
2 | |
3 | import de.uka.ipd.sdq.measurement.strategies.activeresource.AbstractDemandStrategy; |
4 | import de.uka.ipd.sdq.measurement.strategies.activeresource.ResourceTypeEnum; |
5 | |
6 | public class FibonacciDemand extends AbstractDemandStrategy { |
7 | |
8 | public FibonacciDemand() { |
9 | super(-3,0,2,10000,5000); |
10 | } |
11 | |
12 | private long fibonacci(double iterationCount) { |
13 | long i1 = 1; |
14 | long i2 = 1; |
15 | long i3 = 0; |
16 | for (long i = 0; i < iterationCount; i++) { |
17 | i3 = i1 + i2; |
18 | i2 = i1; |
19 | i1 = i3; |
20 | } |
21 | return i3; |
22 | } |
23 | |
24 | @Override |
25 | public void run(long initial) { |
26 | fibonacci(initial); |
27 | } |
28 | |
29 | @Override |
30 | public ResourceTypeEnum getStrategysResource() { |
31 | return ResourceTypeEnum.CPU; |
32 | } |
33 | |
34 | @Override |
35 | public String getName() { |
36 | return "Fibonacci"; |
37 | } |
38 | |
39 | @Override |
40 | public void cleanup() { |
41 | // Do nothing. |
42 | } |
43 | |
44 | } |