I have downloaded and testing these two mapping libraries. I wrote a program which has 100000 iterations and maps the beans of the same class:
public class IntBean {
@JMap
private int int1;
@JMap
private int int2;
.
.
.
@JMap
private int int10;
}
Mappers are created BEFORE iterations start:
private JMapper jmapper = new JMapper(IntBean.class, IntBean.class);
private MapperFactory orikaFactory = new DefaultMapperFactory.Builder().build();
private MapperFacade orikaFacade = null;
orikaFactory.registerClassMap(orikaFactory.classMap(IntBean.class,IntBean.class).byDefault().toClassMap());
orikaFacade = orikaFactory.getMapperFacade();
What is in each iteration:
this.orikaFacade.map(a1, a2);
or
a2 = (A) this.jmapper2.getDestination(a1);
Hand mapping: 1ms
Orika mapping: 32ms
Hand mapping: 6ms GREAT SPEED !!!
Dozer: 1140ms
I know, that Orika and Jmapper are great libraries from Google and they use reflection in a different way than for example Dozer, which is much slower, they se reflection to generete code somehow..
I have 3 questions:
1) How they work - when the code is generated, during maven build, in runtime - everytime when I create mapper in code? Are they change class code byte dynamically when I create mappers.?
2) Why there is this speed difference that I noticed? If the generate code somehow, then why there are different results
3) Which library would you choose and why? Both have the same capabilities? Why both come from Google? Why Google didnt develop Orika and created Jmapper instead?