using Dexih.Utils.CopyProperties;
using System.Collections.Generic;
using System.Diagnostics;
namespace PerformanceCompare
const int RowCount = 500;
public static void Main(string[] args)
Console.WriteLine("Create class");
Stopwatch stopwatch = Stopwatch.StartNew();
var original = new SampleClass();
original.InitSamples(RowCount);
Console.WriteLine("Time to create sample class: " + stopwatch.Elapsed);
var copyClass = original.CloneProperties<SampleClass>();
Console.WriteLine("Time to copy empty class: " + stopwatch.Elapsed);
original.CopyProperties(copyClass);
Console.WriteLine("Time to copy populated class: " +stopwatch.Elapsed);
var serialized = JsonConvert.SerializeObject(original);
var searlizedCopy = JsonConvert.DeserializeObject<SampleClass>(serialized);
Console.WriteLine("Time to copy via json serialize: " +stopwatch.Elapsed);
public string value1 { get; set; }
public ChildClass[] values2 { get; set; }
public List<ChildClass> children { get; set; }
public void InitSamples(long size)
values2 = new ChildClass[size];
children = new List<ChildClass>();
for(var i = 0; i< size; i++)
var child = new ChildClass()
values = new string[] { "123", "123", "123" }
var child2 = new ChildClass()
values = new string[] { "123", "123", "123" }
public long key { get; set; }
public string[] values { get; set; }