Please note this is an excerpt from Chapter 9 of my ASP.NET MVC 5 with Bootstrap and Knockout.js book. In this chapter I provide a brief overview of the 5 different MVC filters and then over the next two chapters provide detail examples of each. The following post is leveraging the example of a Result Filter.
Tag: automapper
-
Automapper Performance Testing
I hate typing more lines of code then I need to; especially something as simple as mapping a domain model to a view model. Enter Automapper!
By performing a one-liner: [code] Mapper.Map<Customer, CustomerViewItem>(customer);[/code] I can quickly map my domain models to my view models.
I was recently reviewing an old article on CodeProject: http://www.codeproject.com/Articles/61629/AutoMapper that contains a quick and easy demo. Inside this article, it discusses performance and it indicates that Automapper is 7 times slower than manual mapping. This test was done on 100,000 records and I must say I was shocked.
My first thought is this requires more testing. Especially since 100,000 records is a lot. In most scenarios I would estimate my largest mapping might be 1,000, but even 1 would probably be a very regular use-case. Let’s put it to the test…