NHibernate: How much slow because the use of reflection?


NHibernate (as a lot of frameworks of IoC) has reflection optimizers to create objects, set and get field/properties. So you don’t have to be worried about that matter: NHibernate isn’t using a plain reflection approach.

This could be an very good argument at the time to “sell NHibernate” to: a customer, a Company or my boss. Have a look on the results of a demo proyect:

As you can see the use of the reflection optimized is faster than the use of reflection. Obviously direct access is the fastest way, but impossible to use in a ORM like NHibernate (as in many other frameworks).

Conclusions

  • Using reflection-optimizer, make the application faster than using of a plain reflection-approach.
  • Field access is faster than property access. This could be a good argument at time to choose field instead of property approach in our mappings files.
  • The obviously but we have to said it: direct access is always the fastest way.

You can download the demo application here.

Thanks to Fabio Maulo to make this example looks nicer. Gracias che !

  1. No comments yet.
(will not be published)

  1. No trackbacks yet.