AutoMapper损害了.net应用程序在映射时具有超过1327个DTO的性能 [英] AutoMapper hurting performance in .net application having more than 1327 DTO while mapping

查看:121
本文介绍了AutoMapper损害了.net应用程序在映射时具有超过1327个DTO的性能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在点网应用程序中使用了AutoMapper 3.1.1.0 . 我们有很多需要学习的课程. 初始化映射所需的时间将近22秒. 我们几乎有 1327 DTO 需要映射.

We are using AutoMapper 3.1.1.0 in our Dot net application. We are having lots of classes which neeed to map. Time required to initialize mapping is almost 22 seconds. We are having almost 1327 DTO which need to mapped.

我们可以说每个DTO平均具有8个属性.

And we can say that each DTO having average 8 properties.

我担心的是,对于我们签入的1327个映射DTO列表中的每条消息,
然后使用

My concern is for each message we check in list of 1327 mapped DTO,
and then use

 if (MappingManager.MessageMappings.ContainsKey(message.GetType()))
            {
                var myMessage = Mapper.Map(message, message.GetType(), MappingManagerFile.MessageMappings[message.GetType()]);

因此,它会损害性能. 使用后我们是否需要处置,还是自动映射器需要自理? 在任务管理器中,执行此转换的组件会占用大量内存.

So it hurts performance. Do we need to Dispose after use, or automapper take care itself? In task manager the component which do this conversion is taking lots of memory.

因此,请提出我们需要使用哪些替代方法来提高性能.

So please suggest what alterantives we need to use to improve performance.

推荐答案

AutoMapper的更高版本会延迟编译配置.仍然有一些启动时间,需要发现和映射类型,但是编译运行时映射函数的工作比较懒惰.

Later versions of AutoMapper lazily compile the configuration. There's still some startup time, discovering and mapping types, but compiling the runtime mapping function is done lazily.

我建议尝试5.0版本并比较数字.

I would suggest trying the 5.0 release and comparing the numbers.

这篇关于AutoMapper损害了.net应用程序在映射时具有超过1327个DTO的性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆