View Javadoc

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.benchmarktests;
28  
29  import org.perfidix.annotation.AfterBenchClass;
30  import org.perfidix.annotation.AfterEachRun;
31  import org.perfidix.annotation.AfterLastRun;
32  import org.perfidix.annotation.BeforeBenchClass;
33  import org.perfidix.annotation.BeforeEachRun;
34  import org.perfidix.annotation.BeforeFirstRun;
35  import org.perfidix.annotation.Bench;
36  
37  /**
38   * One complete Bench, just looking if everthing is going well.
39   * 
40   * @author Sebastian Graf, University of Konstanz
41   */
42  public final class NormalCompleteBench {
43  
44      /** Static for setting number of runs */
45      public final static int RUNS = 25;
46  
47      private static int beforeClassC = 0;
48      private static int beforeFirstRunC = 0;
49      private static int beforeEachRunC = 0;
50      private static int benchC1 = 0;
51      private static int benchC2 = 0;
52      private static int afterEachC = 0;
53      private static int afterLastC = 0;
54      private static int afterClassC = 0;
55  
56      /**
57       * before benchclass
58       */
59      @BeforeBenchClass
60      public void beforeClass() {
61          beforeClassC++;
62      }
63  
64      /**
65       * before firstrun
66       */
67      @BeforeFirstRun
68      public void beforeFirstRun() {
69          beforeFirstRunC++;
70      }
71  
72      /**
73       * before eachrun
74       */
75      @BeforeEachRun
76      public void beforeEachRun() {
77          beforeEachRunC++;
78      }
79  
80      /**
81       * Bench
82       */
83      @Bench(runs = RUNS)
84      public void bench1() {
85          benchC1++;
86      }
87  
88      /**
89       * Bench
90       */
91      @Bench
92      public void bench() {
93          benchC2++;
94      }
95  
96      /**
97       * after eachrun
98       */
99      @AfterEachRun
100     public void afterEachRun() {
101         afterEachC++;
102     }
103 
104     /**
105      * before eachrun
106      */
107     @AfterLastRun
108     public void afterLastRun() {
109         afterLastC++;
110     }
111 
112     /**
113      * after benchclass
114      */
115     @AfterBenchClass
116     public void afterClass() {
117         afterClassC++;
118     }
119 
120     /**
121      * Resetting everything
122      */
123     public static void reset() {
124         beforeClassC = 0;
125         beforeEachRunC = 0;
126         beforeFirstRunC = 0;
127         benchC1 = 0;
128         benchC2 = 0;
129         afterClassC = 0;
130         afterEachC = 0;
131         afterLastC = 0;
132     }
133 
134     /**
135      * Getter for member beforeClassC
136      * 
137      * @return the beforeClassC
138      */
139     public static int getBeforeClassCounter() {
140         return beforeClassC;
141     }
142 
143     /**
144      * Getter for member beforeFirstRunC
145      * 
146      * @return the beforeFirstRunC
147      */
148     public static int getBeforeFirstRunCounter() {
149         return beforeFirstRunC;
150     }
151 
152     /**
153      * Getter for member beforeEachRunC
154      * 
155      * @return the beforeEachRunC
156      */
157     public static int getBeforeEachRunCounter() {
158         return beforeEachRunC;
159     }
160 
161     /**
162      * Getter for member benchC
163      * 
164      * @return the benchC
165      */
166     public static int getBenchCounter1() {
167         return benchC1;
168     }
169 
170     /**
171      * Getter for member benchC
172      * 
173      * @return the benchC
174      */
175     public static int getBenchCounter2() {
176         return benchC2;
177     }
178 
179     /**
180      * Getter for member afterEachC
181      * 
182      * @return the afterEachC
183      */
184     public static int getAfterEachRunCounter() {
185         return afterEachC;
186     }
187 
188     /**
189      * Getter for member afterLastC
190      * 
191      * @return the afterLastC
192      */
193     public static int getAfterLastRunCounter() {
194         return afterLastC;
195     }
196 
197     /**
198      * Getter for member afterClassC
199      * 
200      * @return the afterClassC
201      */
202     public static int getAfterClassCounter() {
203         return afterClassC;
204     }
205 
206 }