This project is read-only.

Where/how to store and bootstrap/configure mappings

Aug 31, 2012 at 1:47 PM

Since there is a performance overhead when using reflection I wonder if you have any advice or best practice for "storing" the mappings and bootstrap/configure these on application startup. Similar to what is discussed for AutoMapper in this thread on StackOverflow:

Sep 1, 2012 at 8:07 PM

Reflection (which most mappers rely on) and performance is a complex thing. I found that the type of reflection to choose, highly depends on how many times you are going to map between the same types in the apps lifetime. See my blogpost on the subject.

I assume Automapper uses the strategy of compiling and invoking expressions. Here the expressions will have to be called more than 200 times in order to start saving time compared to normal reflection. This will work with automapper if you compile the expression in the global.asax, but will be extremely slow if you're not mapping it in such a context.

As Glues motto is "general purpose", it can't be extremely slow on other contexts than long lived ones (like a website). Glue have therefore chosen normal reflection, and thus does not have to be "warmed up". So there is no way to speed it up additionally.

I realize this can be a show stopper for some (with lots of mapping and a long lived context), so I've been toying around with some create alternatives, some of which seems will perform extremely well. The only two things that have prevented me from implementing it already is that it will require quite a big refactoring process, and that it will have to be exposed in the API very carefully. You're request have pushed me towards doing something about this. I'll keep you posted!

Sep 3, 2012 at 7:03 AM

Excellent answer, thank you!

Does the alternatives include any of the ideas proposed in this thread: