public static BenchTestObjectA CreateChildInstance(int level) { BenchTestObjectA instance = new BenchTestObjectA(); instance.StringData = Helper.CreateRandomString(128); instance.Integer = 100; List<string> data = new List<string>(); for (int i = 0; i < 5; i++) { data.Add(Helper.CreateRandomString(128)); } instance.Data = data.ToArray(); if (level < 3) { List<BenchTestObjectA> children = new List<BenchTestObjectA>(); for (int i = 0; i < 9; i++) { children.Add(BenchTestObjectA.CreateChildInstance(level + 1)); } instance.Children = children.ToArray(); } return instance; }
public static BenchTestObjectA CreateChildInstance(int level) { BenchTestObjectA instance = new BenchTestObjectA(); instance.StringData = Helper.CreateRandomString(128); instance.Integer = 100; List <string> data = new List <string>(); for (int i = 0; i < 5; i++) { data.Add(Helper.CreateRandomString(128)); } instance.Data = data.ToArray(); if (level < 3) { List <BenchTestObjectA> children = new List <BenchTestObjectA>(); for (int i = 0; i < 9; i++) { children.Add(BenchTestObjectA.CreateChildInstance(level + 1)); } instance.Children = children.ToArray(); } return(instance); }
private static List<BenchResult> RunTests(BenchTestObjectA instance) { List<BenchResult> results = new List<BenchResult>(); IEnumerable<ISerializerAdapter> serializers = SerializationTests.GetSerializers() .Select(t => (ISerializerAdapter)Activator.CreateInstance(t)); foreach (var ser in serializers) { Console.WriteLine("Benchmarking {0}", ser.GetType().Name); var result = Benchmark.Run(ser, instance); results.Add(result); } return results.OrderBy(r => r.Average.TotalTime).ToList(); }
public void AssertEquality(object other) { Assert.IsNotNull(other); Assert.IsInstanceOfType <BenchTestObjectA>(other); BenchTestObjectA target = other as BenchTestObjectA; Assert.AreEqual(this.StringData, target.StringData); Assert.AreEqual(this.Data, target.Data); if (this.Children != null && target.Children != null) { Assert.AreEqual(this.Children.Count(), target.Children.Count()); for (int i = 0; i < this.Children.Count(); i++) { this.Children[i].AssertEquality(target.Children[i]); } } }