Automapper running extremely slow on mapping 1400 records

前端 未结 4 1191
南旧
南旧 2021-02-19 18:34

I am using AUtomapper which I am very impressed with however, I have a complex object with many nested collections. I\'m using Telerik OpenAccess and it returns the 1400 records

相关标签:
4条回答
  • 2021-02-19 18:47

    There was a team at my previous job who were also using Automapper but in the end they removed it because of the performance impact.

    I think in this specific scenario it's best to write the mapping code yourself, or start replacing them one by one. Maybe one mapping is causing the bad performance?

    0 讨论(0)
  • 2021-02-19 18:54

    I benchmarked automapper. A single core of a 2.0GHz Xeon is able to handle 85,000 maps per second, on a small object (3 properties). It was 60 times slower than manually copying the properties. If you'd like, I can benchmark other values for you.

    0 讨论(0)
  • 2021-02-19 19:05

    For those coming to this later, AutoMapper 5.x release made significant performance improvements, where mapping speed is only slightly slower than hand mapping (1M items):

    • Native: 0.19s
    • AutoMapper: 0.49s
    • AutoMapper 4.2.1: 29s
    0 讨论(0)
  • 2021-02-19 19:07

    I don't think tools like this are designed for mapping so many records. I think AutoMapper is designed for mapping a View Model and it is not normal to display 1400 records on the screen.

    0 讨论(0)
提交回复
热议问题