Clone with better performance

前端 未结 8 2354
一整个雨季
一整个雨季 2020-12-14 04:29

I want to create deep copy method and I found 3 ways to execute it

1-deep copy with pass each property 1 by 1

2-using reflection

3-using serializatio

8条回答
  •  时光取名叫无心
    2020-12-14 05:00

    I made graph with comparison of the three methods plus an expression trees method.

    For large number of objects is reflection 5x faster and manual code and expression trees are 20x faster than serialization. The best by performance are therefore manual code and expression trees.

    Links to used cloning codes (2.-4. used as an extension method):

    1. Manual: Written manually, no link.
    2. Cloning by Serialization
    3. Cloning by Reflection
    4. Cloning by Expression Trees

提交回复
热议问题