EMMA Coverage Report (generated Sun Feb 05 10:43:15 CET 2012)
[all classes][de.uka.ipd.sdq.measurement.strategies.activeresource.cpu]

COVERAGE SUMMARY FOR SOURCE FILE [CalculatePrimesDemand.java]

nameclass, %method, %block, %line, %
CalculatePrimesDemand.java0%   (0/1)0%   (0/6)0%   (0/75)0%   (0/22)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class CalculatePrimesDemand0%   (0/1)0%   (0/6)0%   (0/75)0%   (0/22)
CalculatePrimesDemand (): void 0%   (0/1)0%   (0/11)0%   (0/3)
calculatePrime (double): long 0%   (0/1)0%   (0/53)0%   (0/14)
cleanup (): void 0%   (0/1)0%   (0/1)0%   (0/1)
getName (): String 0%   (0/1)0%   (0/2)0%   (0/1)
getStrategysResource (): ResourceTypeEnum 0%   (0/1)0%   (0/2)0%   (0/1)
run (long): void 0%   (0/1)0%   (0/6)0%   (0/2)

1package de.uka.ipd.sdq.measurement.strategies.activeresource.cpu;
2 
3import de.uka.ipd.sdq.measurement.strategies.activeresource.AbstractDemandStrategy;
4import de.uka.ipd.sdq.measurement.strategies.activeresource.ResourceTypeEnum;
5 
6public class CalculatePrimesDemand extends AbstractDemandStrategy {
7 
8        /** number to start the search with */
9        private final long number = 2;
10 
11        /**
12         * Initialize the search for the next given number of primes
13         */
14        public CalculatePrimesDemand() {
15                super(-3, 0, 3, 100, 100);
16        }
17 
18        /**
19         * Search for the next primes.
20         */
21        private long calculatePrime(double numberNextPrimes) { 
22                
23                boolean isPrime = true;
24                long currentNumber = number;
25                long primesFound = 0;
26                long currentDivisor;
27                long upperBound;
28 
29                while (primesFound < numberNextPrimes) {
30                        // test primality of currentNumber
31                        currentDivisor = 2;
32                        upperBound = currentNumber / 2;
33                        while ((currentDivisor < upperBound) && (isPrime)) {
34                                isPrime = currentNumber % currentDivisor != 0;
35                                currentDivisor++;
36                        }
37                        // count primes and continue
38                        if (isPrime) {
39                                primesFound++;
40                        }
41                        // prepare for next iteration
42                        isPrime = true;
43                        currentNumber++;
44                }
45                return currentNumber;
46        }
47 
48        @Override
49        public void run(long initial) {
50                calculatePrime(initial);
51        }
52 
53        @Override
54        public ResourceTypeEnum getStrategysResource() {
55                return ResourceTypeEnum.CPU;
56        }
57 
58        @Override
59        public String getName() {
60                return "CalculatePrimes";
61        }
62 
63        @Override
64        public void cleanup() {
65                // Do nothing.
66        }
67}

[all classes][de.uka.ipd.sdq.measurement.strategies.activeresource.cpu]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov