When the need arises to clone an object, Microsoft recommends the approach of serializing it to JSON and subsequently deserializing the JSON to create a new object. I was intrigued to explore how performance varies when dealing with reference types, value types, and record types.
Benchmark Results
Using the JsonSerializer for cloning, it was observed that cloning record types is 1.12 times faster than cloning a value type and 1.23 times more performant than cloning reference types. These findings are provided for your reference.


Pick up any books by David McCarter by going to Amazon.com: http://bit.ly/RockYourCodeBooks
Make a one-time donation
Make a monthly donation
Make a yearly donation
Choose an amount
Or enter a custom amount
Your contribution is appreciated.
Your contribution is appreciated.
Your contribution is appreciated.
DonateDonate monthlyDonate yearlyIf you liked this article, please buy David a cup of Coffee by going here: https://www.buymeacoffee.com/dotnetdave
© The information in this article is copywritten and cannot be preproduced in any way without express permission from David McCarter.
Discover more from dotNetTips.com
Subscribe to get the latest posts sent to your email.

