public void Setup() { _serializer = new Serializer(); _stream = new MemoryStream(); _testStruct = LargeStruct.Create(); _testPerson = TypicalPersonData.MakeRandom(); }
static void Main(string[] args) { var _serializer = new Serializer(); var _stream = new MemoryStream(); var _testPerson = TypicalPersonData.MakeRandom(); Stopwatch serializeWatch = new Stopwatch(); Stopwatch deserializeWatch = new Stopwatch(); float times = 2f; for (int i = 0; i < times; i++) //while (true) { serializeWatch.Start(); _serializer.Serialize(_testPerson, _stream); serializeWatch.Stop(); _stream.Seek(0, SeekOrigin.Begin); deserializeWatch.Start(); _serializer.Deserialize(_stream); deserializeWatch.Stop(); _stream.Seek(0, SeekOrigin.Begin); } Console.WriteLine($"Serialize Avg. Time: {serializeWatch.ElapsedMilliseconds / times}ms"); Console.WriteLine($"Deserialize Avg. Time: {deserializeWatch.ElapsedMilliseconds / times}ms"); Console.ReadKey(); }
protected override TypicalPersonData[] GetValue() { var l = new List <TypicalPersonData>(); for (int i = 0; i < 100; i++) { l.Add(TypicalPersonData.MakeRandom()); } return(l.ToArray()); }
public override void Setup(BenchmarkContext context) { base.Setup(context); _testStruct = LargeStruct.Create(); _testObject = TypicalPersonData.MakeRandom(); var a = new CyclicA(); var b = new CyclicB(); a.B = b; b.A = a; _cyclic = a; }
public override void Setup(BenchmarkContext context) { base.Setup(context); InitStreamWith(TypicalPersonData.MakeRandom()); }
public void Setup() { _persionData = TypicalPersonData.MakeRandom(); }