1 | package de.uka.ipd.sdq.statistics.test; |
2 | |
3 | import java.io.File; |
4 | import java.util.ArrayList; |
5 | import java.util.Collection; |
6 | import java.util.List; |
7 | |
8 | import junit.framework.TestCase; |
9 | import de.uka.ipd.sdq.sensorframework.dao.file.FileDAOFactory; |
10 | import de.uka.ipd.sdq.sensorframework.entities.Measurement; |
11 | import de.uka.ipd.sdq.sensorframework.entities.TimeSpanMeasurement; |
12 | import de.uka.ipd.sdq.sensorframework.entities.dao.IDAOFactory; |
13 | import de.uka.ipd.sdq.statistics.CrossingMeanWarmUpFilter; |
14 | |
15 | /** |
16 | * Tests the {@link CrossingMeanWarmUpFilter}. This test case is intended for |
17 | * manual testing only. For evaluating the outcome the date series needs to be |
18 | * plotted (e.g. as time series) and compared manually. |
19 | * |
20 | * @author Philipp Merkle |
21 | * |
22 | */ |
23 | public class TestCrossingMeanWarmUpFilter extends TestCase { |
24 | |
25 | public void testWarmUpFilter() { |
26 | // Adjust path to data store here! |
27 | String dataStorePath = "D:\\Studium\\Master\\HiWi IPD\\runtime-150909\\brs\\Data4"; |
28 | |
29 | File dataStoreFolder = new File(dataStorePath); |
30 | if (dataStoreFolder.exists()) { |
31 | IDAOFactory factory = new FileDAOFactory(dataStorePath); |
32 | Collection<Measurement> measurements = TestUtils.loadMeasurements( |
33 | factory, 0, 0, 24); |
34 | |
35 | List<Double> samples = new ArrayList<Double>(measurements.size()); |
36 | for (Measurement m : measurements) { |
37 | TimeSpanMeasurement tsm = (TimeSpanMeasurement) m; |
38 | samples.add(tsm.getTimeSpan()); |
39 | } |
40 | |
41 | CrossingMeanWarmUpFilter filter = new CrossingMeanWarmUpFilter(); |
42 | int i = 0; |
43 | for (Double sample : samples) { |
44 | filter.offerSample(sample); |
45 | if (filter.isStationary()) { |
46 | System.out.println("Warm-Up Peroid: Up to measurement " + i); |
47 | break; |
48 | } |
49 | ++i; |
50 | } |
51 | |
52 | factory.finalizeAndClose(); |
53 | } else { |
54 | System.err.println("Could not find data store path \"" |
55 | + dataStorePath + "\""); |
56 | } |
57 | } |
58 | |
59 | } |