I downloaded and tested these two mapping libraries. I wrote a program that has 100,000 iterations and displays beans of the same class:
public class IntBean { @JMap private int int1; @JMap private int int2; . . . @JMap private int int10; }
Mappers are created BEFORE starting iterations:
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 at each iteration:
this.orikaFacade.map(a1, a2);
or
a2 = (A) this.jmapper2.getDestination(a1);
Manual display: 1 ms
Orika Display: 32 ms
Hand mapping: 6 ms BIG SPEED !!!
Bulldozer: 1140 ms
I know that Orika and Jmapper are different libraries from Google, and they use reflection differently than, for example, Dozer, which is much slower, they reflect the code generator somehow ..
I have 3 questions:
1) How do they work - when the code is generated during the maven build at runtime - every time I create a mapper in the code? Are they dynamically changing bytes of class code when I create mappers.?
2) Why is there such a difference in speed that I noticed? If you generate the code in some way, then why there are different results
3) Which library would you choose and why? Both have the same features? Why are both from Google? Why didn’t Google develop Orika and create Jmapper?
java mapping orika
user1308908
source share