Hello,Result:
My name is Douglas, I and my team are looking for an API to replace relfection and improve performance.
Then find your project Refletasm, we downloaded the library and did some tests.
In one of our tests using the latest version of your library and java 7, we note that Reflection behaved much faster than Reflectasm.
I would like to know the best way to use your library and if we perform the tests correctly.
Thank you for your attention and congratulations for the initiative.
Hugs.
int qtd = 1000000;
long tempoInicio = System.currentTimeMillis();
for (int i = 0; i < qtd; i++) {
Pessoa someObject = new Pessoa();
someObject.setNome("teste");
someObject.setId(10);
someObject.setAtivo(true);
}
System.out.println("Normal execution: "+(System.currentTimeMillis()-tempoInicio));
tempoInicio = System.currentTimeMillis();
for (int i = 0; i < qtd; i++) {
ConstructorAccess<Pessoa> cAccess = ConstructorAccess
.get(Pessoa.class);
Pessoa someObject = cAccess.newInstance();
MethodAccess mAccess = MethodAccess.get(Pessoa.class);
mAccess.invoke(someObject, "setNome", "Awesome McLovin");
mAccess.invoke(someObject, "setId", 1);
mAccess.invoke(someObject, "setAtivo", true);
}
System.out.println("Reflectasm: "+(System.currentTimeMillis()-tempoInicio));
tempoInicio = System.currentTimeMillis();
for (int i = 0; i < qtd; i++) {
Class c = Class.forName("br.com.testereflectasm.Pessoa");
Pessoa a = (Pessoa) c.newInstance();
a.getClass().getMethod("setNome", String.class).invoke(a,"teste");
a.getClass().getMethod("setId", Integer.class).invoke(a,1);
a.getClass().getMethod("setAtivo", Boolean.class).invoke(a,true);
}
System.out.println("Reflection: "+(System.currentTimeMillis()-tempoInicio));
tempoInicio = System.currentTimeMillis();
}
Normal execution: 32 ms
Reflectasm: 16341 ms
Reflection: 8089 ms
Thank you for the reply.
Really, removing the creation of these objects out of the loop performance improved greatly.
Normal call: 24
Reflectasm: 299
Reflection: 4301
Reflectutils: 3873
We are developing an ORM persistence for Java and Android, and the question is that in Android are having a considerable loss of performance fault of Reflection.
We will study more deeply the Reflectasm.
Hugs.
2013/9/12 Nate <nathan...@gmail.com>