by Paulo Morgado via Paulo Morgado : C# on 8/18/2010 1:27:14 AM
To finalize this series on object hydration, I’ll show some performance comparisons between the different methods of hydrating objects.
For the purpose of this exercise, I’ll use this class:
class SomeType { public int Id { get; set; } public string Name { get; set; } public DateTimeOffset CreationTime { get; set; } public Guid UniqueId { get; set; } }
and this set of data:
var data = ( from i in Enumerable.Range(1, ObjectCount) select new object[] { i, i.ToString(), DateTimeOffset.Now, Guid.NewGuid() } ).ToArray();
The data bellow shows the time (in seconds) for different runs for different values of ObjectCount (in the same machine with approximately the same load) as well as it’s availability for different version of the .NET Framework and the C# programming language:
These values will vary with the number of the objects being hydrated and the number of its properties, but the method using the Member Initializer will be the most performant.
Code samples for this series of posts (and the one about object dumping with expression trees) can be found on my MSDN Code Gallery: Dump And Hydrate Objects With Expression Trees
Original Post: Hydrating Objects With Expression Trees - Part III
The content of the postings is owned by the respective author. CSharpFeeds is not responsible for the contents of the postings. This site is automatically generated and cannot be reviewed for abusive content. If you find abusive content on CSharpFeeds, please contact us. Designated trademarks and brands are the property of their respective owners. All rights reserved.