-
Notifications
You must be signed in to change notification settings - Fork 0
/
TestReflectionVsSynapse.java
45 lines (35 loc) · 1.33 KB
/
TestReflectionVsSynapse.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package com.synapse;
import org.junit.Test;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class TestReflectionVsSynapse {
@Test
public void doSynapse() {
long start = System.currentTimeMillis();
for (int i = 0; i < 1000000; i++) {
FeatureManager.initFeature("com.synapse.MainActivityJava", "functionA", "dfs", 2);
}
System.out.println(System.currentTimeMillis() - start);
}
@Test
public void doReflection() {
long start = System.currentTimeMillis();
for (int i = 0; i < 1000000; i++) {
try {
Class<?> a = Class.forName("com.synapse.MainActivityJava");
Object[] values = new Object[]{new Object[]{"dfs", 2}};
Method bt1click = a.getDeclaredMethod("functionA", Object[].class);
bt1click.invoke(null, values);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
System.out.println(System.currentTimeMillis() - start);
}
}