How slow is Reflection

后端 未结 7 2043
时光取名叫无心
时光取名叫无心 2020-12-02 07:43

I recently created an interface layer to distinguish the DataAccessProvider from our Business logic layer. With this approach we can change our choice of DataAccessProvider

7条回答
  •  感情败类
    2020-12-02 08:03

    Its slower compared to non-reflective code. The important thing is not if its slow, but if its slow where it counts. For instance, if you instantiate objects using reflection in web environment where expected concurency can rise up to 10K, it will be slow.

    Anyway, its good not to be concerned about performance in advance. If things turns out to be slow, you can always speed them up if you designed things correctly so that parts that you expected might be in need of optimisation in future are localised.

    You can check this famous article if you need speed up:

    Dynamic... But Fast: The Tale of Three Monkeys, A Wolf and the DynamicMethod and ILGenerator Classes

提交回复
热议问题