Skip to content

Commit 180b23f

Browse files
committed
update the demo to use the correct wrapper
1 parent 28a1827 commit 180b23f

4 files changed

Lines changed: 21 additions & 6 deletions

File tree

codegen/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

12+
<name>codegen</name>
1213
<artifactId>codegen</artifactId>
1314

1415
<dependencies>

indy/src/main/java/com/github/mustachejava/indy/IndyWrapper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ protected IndyWrapper(ReflectionWrapper rw) {
5454

5555
public abstract Object call(Object[] scopes) throws GuardException; // {
5656

57-
public static IndyWrapper create(ReflectionWrapper rw) {
57+
public static IndyWrapper create(CodegenReflectionWrapper rw) {
5858
return create(rw, true);
5959
}
6060

61-
public static IndyWrapper create(ReflectionWrapper rw, boolean guard) {
61+
public static IndyWrapper create(CodegenReflectionWrapper rw, boolean guard) {
6262
String name;
6363
Method method = rw.getMethod();
6464
if (method == null) {

indy/src/test/java/IndyDemo.java

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
import com.github.mustachejava.codegen.CodegenObjectHandler;
2+
import com.github.mustachejava.codegen.CodegenReflectionWrapper;
13
import com.github.mustachejava.indy.IndyWrapper;
24
import com.github.mustachejava.reflect.ReflectionObjectHandler;
3-
import com.github.mustachejava.reflect.ReflectionWrapper;
45
import com.github.mustachejava.util.Wrapper;
56
import org.junit.Test;
67

@@ -14,6 +15,7 @@ public static void main(String[] args) throws Throwable {
1415
IndyDemo indyDemo = new IndyDemo();
1516
for (int i = 0; i < 10; i++) {
1617
timeReflectionOH(indyDemo);
18+
timeCodegenReflectionOH(indyDemo);
1719
timeIndyOH(indyDemo);
1820
timeIndyOHNoGuard(indyDemo);
1921
timeReflection(indyDemo);
@@ -31,6 +33,15 @@ public static void timeReflectionOH(IndyDemo indyDemo) throws Throwable {
3133
System.out.println("reflection OH: " + (System.currentTimeMillis() - start));
3234
}
3335

36+
public static void timeCodegenReflectionOH(IndyDemo indyDemo) throws Throwable {
37+
long start = System.currentTimeMillis();
38+
Object[] scopes = {indyDemo};
39+
for (int i = 0; i < TIMES; i++) {
40+
CODEGEN_REFLECTED.call(scopes);
41+
}
42+
System.out.println("codegen reflection OH: " + (System.currentTimeMillis() - start));
43+
}
44+
3445
@Test
3546
public void timeIndyOH() throws Throwable {
3647
for (int i = 0; i < 10; i++) {
@@ -95,11 +106,14 @@ public static void timeDirect(IndyDemo indyDemo) throws Throwable {
95106
private static Wrapper INDY;
96107
private static IndyWrapper INDY_NOGUARD;
97108

109+
private static Wrapper CODEGEN_REFLECTED;
110+
98111
static {
99112
IndyDemo indyDemo = new IndyDemo();
100113
REFLECTED = new ReflectionObjectHandler().find("someMethod", new Object[] { indyDemo });
101-
INDY = IndyWrapper.create((ReflectionWrapper) REFLECTED);
102-
INDY_NOGUARD = IndyWrapper.create((ReflectionWrapper) REFLECTED, false);
114+
CODEGEN_REFLECTED = new CodegenObjectHandler().find("someMethod", new Object[] { indyDemo });
115+
INDY = IndyWrapper.create((CodegenReflectionWrapper) CODEGEN_REFLECTED);
116+
INDY_NOGUARD = IndyWrapper.create((CodegenReflectionWrapper) CODEGEN_REFLECTED, false);
103117
}
104118

105119
private int length = 0;

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
<modules>
1010
<module>compiler</module>
1111
<module>handlebar</module>
12-
<module>indy</module>
1312
<module>codegen</module>
13+
<module>indy</module>
1414
</modules>
1515
<packaging>pom</packaging>
1616

0 commit comments

Comments
 (0)