简体   繁体   English

推土机映射:通过XML映射与通过API映射。 哪一个执行得更快?

[英]Dozer Mapping: Mapping via XML vs Mapping via API. Which one performs faster?

In my project, i'm using dozer mapping via XML. 在我的项目中,我正在通过XML使用推土机映射。 But my project teams asking me to use Mapping via API. 但是我的项目团队要求我通过API使用Mapping。 They claim that mapping via API will be faster than XML , as mapping via api is compiled code already. 他们声称通过API进行映射将比XML快,因为通过api进行映射已经是编译代码。

Kindly help me understand whether this mapping via API is really faster than mapping via XML. 请帮助我了解通过API进行映射是否真的比通过XML进行映射更快。

I think your team may be missing the point. 我认为您的团队可能没有抓住重点。 Remember that all you are doing when you are supplying either XML or API mapping to Dozer is configuring it. 请记住,当您向Dozer提供XML或API映射时,您正在做的所有事情就是对其进行配置 You're not actually mapping anything at config time, and configuration usually only happens once at application startup. 您实际上并没有在配置时映射任何内容,并且配置通常仅在应用程序启动时发生一次。

Once configured, both approaches use the same reflection based engine to do the grunt work of the actual mapping using a call like this (amongst other options): 配置完成后,这两种方法都使用相同的基于反射的引擎,通过这样的调用(以及其他选项)来完成实际映射的艰巨工作:

DestinationObject destObject = mapper.map(sourceObject, DestinationObject.class);

If you're really concerned about mapping performance; 如果您真的担心映射性能; then map manually with gets/sets. 然后使用获取/设置手动进行映射。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM