[SUBMIT] Some experiment to make reflection faster
"Juozas Baliuka" <[email protected]>
| Newsgroups | gmane.comp.jakarta.bcel.devel |
|---|---|
| Message-ID | <008701c204c0$5956ae00$0111010a@user> |
It can be used to implements "fast" reflection,
this class implements only "newInstance" at this time.
Usage :
System.out.println( "java version:" +
System.getProperty("java.specification.version"));
Reflect reflect = Reflect.getReflect(java.util.Vector.class);
long time = System.currentTimeMillis();
for( int i=0; i< 1000000; i++ ){
Object tmp = (java.util.Vector)reflect.newInstance();
}
long br = System.currentTimeMillis() - time;
System.out.println("BCEL REFLECT : " + br + " ms.");
time = System.currentTimeMillis();
for( int i=0; i< 1000000; i++ ){
Object tmp =
(java.util.Vector)java.util.Vector.class.newInstance();
}
long jr = System.currentTimeMillis() - time;
System.out.println("JAVA REFLECT : " + jr + " ms.");
System.out.println( Math.round(( 1 - br/(double)jr )*100) + " %" );
}
Output ( SUN's JVM 1.4 for windows) :
java version:1.4
BCEL REFLECT : 281 ms.
JAVA REFLECT : 406 ms.
31 %
Diference is more significant on 1.3
--
To unsubscribe, e-mail: <mailto:[email protected]>
For additional commands, e-mail: <mailto:[email protected]>
Reflect.java
(application/octet-stream, 6.2 KB) - not displayed