1+ import com .github .mustachejava .codegen .CodegenObjectHandler ;
2+ import com .github .mustachejava .codegen .CodegenReflectionWrapper ;
13import com .github .mustachejava .indy .IndyWrapper ;
24import com .github .mustachejava .reflect .ReflectionObjectHandler ;
3- import com .github .mustachejava .reflect .ReflectionWrapper ;
45import com .github .mustachejava .util .Wrapper ;
56import 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 ;
0 commit comments