1
1
package com .github .mustachejavabenchmarks ;
2
2
3
3
import com .github .mustachejava .*;
4
- import junit .framework .TestCase ;
4
+ import org .junit .Before ;
5
+ import org .junit .Test ;
5
6
6
7
import java .io .File ;
7
8
import java .io .IOException ;
15
16
* Date: 5/14/11
16
17
* Time: 9:28 PM
17
18
*/
18
- public class BenchmarkTest extends TestCase {
19
+ public class BenchmarkTest {
19
20
private static final int TIME = 2000 ;
20
21
protected File root ;
21
22
22
- protected void setUp () throws Exception {
23
- super . setUp ();
23
+ @ Before
24
+ public void setUp () throws Exception {
24
25
File file = new File ("src/test/resources" );
25
26
root = new File (file , "simple.html" ).exists () ? file : new File ("../src/test/resources" );
26
-
27
27
}
28
28
29
29
public static boolean skip () {
30
30
return System .getenv ().containsKey ("CI" ) || System .getProperty ("CI" ) != null ;
31
31
}
32
32
33
+ @ Test
33
34
public void testCompiler () {
34
35
if (skip ()) return ;
35
36
System .out .println ("complex.html compilations per second:" );
@@ -48,6 +49,7 @@ public void testCompiler() {
48
49
}
49
50
}
50
51
52
+ @ Test
51
53
public void testComplex () throws MustacheException , IOException {
52
54
if (skip ()) return ;
53
55
System .out .println ("complex.html evaluations per millisecond:" );
@@ -73,6 +75,7 @@ protected DefaultMustacheFactory createMustacheFactory() {
73
75
return new DefaultMustacheFactory ();
74
76
}
75
77
78
+ @ Test
76
79
public void testComplexFlapping () throws MustacheException , IOException {
77
80
if (skip ()) return ;
78
81
System .out .println ("complex.html evaluations with 3 different objects per millisecond:" );
@@ -96,6 +99,7 @@ public void testComplexFlapping() throws MustacheException, IOException {
96
99
}
97
100
}
98
101
102
+ @ Test
99
103
public void testParallelComplex () throws MustacheException , IOException {
100
104
if (skip ()) return ;
101
105
System .out .println ("complex.html evaluations per millisecond:" );
@@ -117,6 +121,7 @@ public void testParallelComplex() throws MustacheException, IOException {
117
121
}
118
122
}
119
123
124
+ @ Test
120
125
public void testParallelComplexNoExecutor () throws MustacheException , IOException {
121
126
if (skip ()) return ;
122
127
System .out .println ("complex.html evaluations per millisecond:" );
@@ -142,14 +147,4 @@ private Writer complextest(Mustache m, Object complexObject) throws MustacheExce
142
147
m .execute (sw , complexObject ).close ();
143
148
return sw ;
144
149
}
145
-
146
- public static void main (String [] args ) throws Exception {
147
- BenchmarkTest benchmarkTest = new BenchmarkTest ();
148
- benchmarkTest .setUp ();
149
- benchmarkTest .testComplex ();
150
- benchmarkTest .testParallelComplex ();
151
- benchmarkTest .testParallelComplexNoExecutor ();
152
- System .exit (0 );
153
- }
154
-
155
150
}
0 commit comments