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 | |
7 | public class CountNumbersDemand extends AbstractDemandStrategy { |
8 | |
9 | // needed to stop the JIT compiler from removing the code in execute |
10 | private long k; |
11 | |
12 | public CountNumbersDemand() { |
13 | super(-3,-1,2,10000,5000); |
14 | } |
15 | |
16 | private void countNumbers(double countTo) { |
17 | for (long j=0; j<countTo; j++){ |
18 | if (k>100000){ |
19 | k=0; |
20 | } |
21 | k+=j; |
22 | } |
23 | } |
24 | |
25 | @Override |
26 | public void run(long initial) { |
27 | countNumbers(initial); |
28 | } |
29 | |
30 | @Override |
31 | public ResourceTypeEnum getStrategysResource() { |
32 | return ResourceTypeEnum.CPU; |
33 | } |
34 | |
35 | @Override |
36 | public String getName() { |
37 | return "CountNumbers"; |
38 | } |
39 | |
40 | @Override |
41 | public void cleanup() { |
42 | // Do nothing. |
43 | } |
44 | } |