-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from ccqy66/master
🐛 fix same method bug
- Loading branch information
Showing
2 changed files
with
61 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.blade.reflectasm; | ||
|
||
import junit.framework.TestCase; | ||
|
||
import java.lang.reflect.Method; | ||
|
||
/** | ||
* @author: chenchen_839@126.com | ||
* @date: 2018/7/18 | ||
*/ | ||
public class SameMethodTest extends TestCase{ | ||
|
||
public void testSame() throws NoSuchMethodException { | ||
MethodAccess access = MethodAccess.get(SameMethodTest.Demo.class); | ||
Demo demo = new Demo(); | ||
Method method = demo.getClass().getMethod("register",String.class); | ||
Object result = null; | ||
long start = System.currentTimeMillis(); | ||
for (int i = 0;i<=100000000;i++) { | ||
result = access.invoke(demo,"register",new Class[]{Integer.class},i); | ||
} | ||
long end = System.currentTimeMillis(); | ||
for (int i = 0;i<=100000000;i++) { | ||
result = access.invoke(demo, method, new Class[]{Integer.class}, i); | ||
} | ||
long fina = System.currentTimeMillis(); | ||
|
||
System.out.println(end-start); | ||
System.out.println(fina - end); | ||
} | ||
|
||
public class Demo{ | ||
public String register(String name) { | ||
return name; | ||
} | ||
public String register(Integer name) { | ||
return name.toString(); | ||
} | ||
} | ||
} |