Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
AbstractConfig |
|
| 1.0;1 | ||||
AbstractConfig$StandardConfig |
|
| 1.0;1 |
1 | /** | |
2 | * Copyright (c) 2012, University of Konstanz, Distributed Systems Group | |
3 | * All rights reserved. | |
4 | * | |
5 | * Redistribution and use in source and binary forms, with or without | |
6 | * modification, are permitted provided that the following conditions are met: | |
7 | * * Redistributions of source code must retain the above copyright | |
8 | * notice, this list of conditions and the following disclaimer. | |
9 | * * Redistributions in binary form must reproduce the above copyright | |
10 | * notice, this list of conditions and the following disclaimer in the | |
11 | * documentation and/or other materials provided with the distribution. | |
12 | * * Neither the name of the University of Konstanz nor the | |
13 | * names of its contributors may be used to endorse or promote products | |
14 | * derived from this software without specific prior written permission. | |
15 | * | |
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | |
17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
19 | * DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY | |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
26 | */ | |
27 | package org.perfidix; | |
28 | ||
29 | import java.util.HashSet; | |
30 | import java.util.Set; | |
31 | ||
32 | import org.perfidix.element.KindOfArrangement; | |
33 | import org.perfidix.meter.AbstractMeter; | |
34 | import org.perfidix.meter.Time; | |
35 | import org.perfidix.meter.TimeMeter; | |
36 | import org.perfidix.ouput.AbstractOutput; | |
37 | ||
38 | /** | |
39 | * Configuration for Benchmark. Simple pass this class through the | |
40 | * Perfidix-Class. Each setting is hold over here. This class must be inherited | |
41 | * by a constructor which has no arguments to provide easy instantiation. This | |
42 | * can be done in the following way: | |
43 | * <p> | |
44 | * | |
45 | * <pre> | |
46 | * | |
47 | * @BenchmarkConfig | |
48 | * public class Config extends AbstractConfig { | |
49 | * private final static int RUNS = 100; | |
50 | * private final static AbstractMeter[] METERS = { | |
51 | * new TimeMeter(Time.MilliSeconds), new MemMeter(Memory.Byte) | |
52 | * }; | |
53 | * private final static AbstractOutput[] OUTPUT = { | |
54 | * new TabularSummaryOutput() | |
55 | * }; | |
56 | * private final static KindOfArrangement ARRAN = KindOfArrangement.SequentialMethodArrangement; | |
57 | * private final static double GCPROB = 1.0d; | |
58 | * | |
59 | * public Config() { | |
60 | * super(RUNS, METERS, OUTPUT, ARRAN, GCPROB); | |
61 | * } | |
62 | * } | |
63 | * | |
64 | * </pre> | |
65 | * | |
66 | * </p> | |
67 | * | |
68 | * @author Sebastian Graf, University of Konstanz | |
69 | */ | |
70 | public abstract class AbstractConfig { | |
71 | ||
72 | /** Standard runs */ | |
73 | public final static int RUNS = 10; | |
74 | ||
75 | /** Standard meters */ | |
76 | 5 | public final static Set<AbstractMeter> METERS = new HashSet<AbstractMeter>(); |
77 | ||
78 | /** Standard listeners */ | |
79 | 5 | public final static Set<AbstractOutput> LISTENERS = new HashSet<AbstractOutput>(); |
80 | ||
81 | /** Standard arrangement */ | |
82 | 5 | public final static KindOfArrangement ARRAN = KindOfArrangement.NoArrangement; |
83 | ||
84 | /** Standard gc-prob */ | |
85 | public final static double GARBAGE_PROB = 1d; | |
86 | ||
87 | /** actual value for runs */ | |
88 | private transient final int runs; | |
89 | ||
90 | /** actual value for meters */ | |
91 | private transient final AbstractMeter[] meters; | |
92 | ||
93 | /** actual value for listeners */ | |
94 | private transient final AbstractOutput[] listeners; | |
95 | ||
96 | /** actual value for runs */ | |
97 | private transient final KindOfArrangement arrangement; | |
98 | ||
99 | /** actual value for gcProb */ | |
100 | private transient final double gcProb; | |
101 | ||
102 | static { | |
103 | 5 | METERS.add(new TimeMeter(Time.MilliSeconds)); |
104 | 5 | } |
105 | ||
106 | /** | |
107 | * Simple constructor. | |
108 | */ | |
109 | protected AbstractConfig(final int paramRuns, final Set<AbstractMeter> paramMeters, | |
110 | 150 | final Set<AbstractOutput> paramOutput, final KindOfArrangement paramArr, final double paramGC) { |
111 | 150 | runs = paramRuns; |
112 | ||
113 | 150 | meters = paramMeters.toArray(new AbstractMeter[paramMeters.size()]); |
114 | 150 | listeners = paramOutput.toArray(new AbstractOutput[paramOutput.size()]); |
115 | ||
116 | 150 | arrangement = paramArr; |
117 | 150 | gcProb = paramGC; |
118 | 150 | } |
119 | ||
120 | /** | |
121 | * Getter for member meters | |
122 | * | |
123 | * @return the meters | |
124 | */ | |
125 | public final AbstractMeter[] getMeters() { | |
126 | 75 | final AbstractMeter[] returnVal = new AbstractMeter[meters.length]; |
127 | 75 | System.arraycopy(meters, 0, returnVal, 0, returnVal.length); |
128 | 75 | return returnVal; |
129 | } | |
130 | ||
131 | /** | |
132 | * Getter for member runs | |
133 | * | |
134 | * @return the runs | |
135 | */ | |
136 | public final int getRuns() { | |
137 | 140 | return runs; |
138 | } | |
139 | ||
140 | /** | |
141 | * Getter for member gcProb | |
142 | * | |
143 | * @return the gcProb | |
144 | */ | |
145 | public final double getGcProb() { | |
146 | 3985 | return gcProb; |
147 | } | |
148 | ||
149 | /** | |
150 | * Getter for member listeners | |
151 | * | |
152 | * @return the listeners | |
153 | */ | |
154 | public final AbstractOutput[] getListener() { | |
155 | 60 | final AbstractOutput[] returnVal = new AbstractOutput[listeners.length]; |
156 | 60 | System.arraycopy(listeners, 0, returnVal, 0, returnVal.length); |
157 | 60 | return returnVal; |
158 | } | |
159 | ||
160 | /** | |
161 | * Getter for member arrangement | |
162 | * | |
163 | * @return the arrangement | |
164 | */ | |
165 | public final KindOfArrangement getArrangement() { | |
166 | 50 | return arrangement; |
167 | } | |
168 | ||
169 | /** | |
170 | * Standard config. | |
171 | * | |
172 | * @author Sebastian Graf, University of Konstanz | |
173 | */ | |
174 | public static class StandardConfig extends AbstractConfig { | |
175 | ||
176 | /** | |
177 | * Constructor. | |
178 | */ | |
179 | public StandardConfig() { | |
180 | 100 | super(RUNS, METERS, LISTENERS, ARRAN, GARBAGE_PROB); |
181 | 100 | } |
182 | ||
183 | } | |
184 | } |