AutoMapper 5.0 speed increases


Just an update on the work we’ve been doing to speed up AutoMapper. I’ve captured times to map some common scenarios (1M mappings). Time is in seconds:

  Flattening Ctor Complex Deep
Native 0.0148 0.0060 0.9615 0.2070
5.0 0.2203 0.1791 2.5272 1.4054
4.2.1 4.3989 1.5608 134.39 29.023
3.3.1 4.7785 1.3384 72.812 34.485
2.2.1 5.1175 1.7855 122.0081 35.863
1.1.0.118 6.7143 n/a 29.222 38.852

The complex mappings had the biggest variation, but across the board AutoMapper is *much* faster than previous versions. Sometimes 20x faster, 50x in others. It’s been a ton of work to get here, mainly from the change in having a single configuration step that let us build execution plans that exactly target your configuration. We now build up an expression tree for the mapping plan based on the configuration, instead of evaluating the same rules over and over again.

We *could* get marginally faster than this, but that would require us sacrificing diagnostic information or not handling nulls etc. Still, not too shabby, and in the same ballpark as the other mappers (faster than some, marginally slower than others) out there. With this release, I think we can officially stop labeling AutoMapper as “slow” 😉

Look for the 5.0 release to drop with the release of .NET Core next week!

10 Lessons from a Long Running DDD Project – Part 2