public void XdrReaderPerformanceTest(int rounds, int iterations) { var testArray = new byte[32]; Array.Fill(testArray, (byte)100); var stream = new XdrBufferWriter(); for (var i = 0; i < iterations; i++) { stream.WriteInt32(435); stream.WriteString("oiewurouqwe"); stream.WriteVariable(testArray); } var serialized = stream.ToArray(); PerfCounter.MeasureTime(() => { for (var r = 0; r < rounds; r++) { var reader = new XdrBufferReader(serialized); for (var i = 0; i < iterations; i++) { reader.ReadInt32(); reader.ReadString(); reader.ReadVariableAsSpan(); } } }, () => $"({rounds} rounds, {iterations} iterations)"); }
public void XdrInputStreamPerformanceTest(int rounds, int iterations) { var testArray = new byte[32]; Array.Fill(testArray, (byte)100); var stream = new XdrDataOutputStream(); for (var i = 0; i < iterations; i++) { stream.WriteInt(435); stream.WriteString("oiewurouqwe"); stream.WriteVarOpaque(32, testArray); } var serialized = stream.ToArray(); PerfCounter.MeasureTime(() => { for (var r = 0; r < rounds; r++) { var reader = new XdrDataInputStream(serialized); for (var i = 0; i < iterations; i++) { reader.ReadInt(); reader.ReadString(); reader.ReadVarOpaque(32); } } }, () => $"({rounds} rounds, {iterations} iterations)"); }
public void OrderbookPerformanceTest(int iterations, bool useNormalDistribution = false) { ExecuteWithOrderbook(iterations, useNormalDistribution, executeOrders => PerfCounter.MeasureTime(executeOrders, () => { var market = Global.Exchange.GetMarket(1); return($"{iterations} iterations, orderbook size: {market.Bids.Count} bids, {market.Asks.Count} asks, {market.Bids.GetBestPrice().ToString("G3")}/{market.Asks.GetBestPrice().ToString("G3")} spread."); })); }
public void XdrPrimitiveTypesSerializationPerformance() { var iterations = 1_000_000; var original = GeneratePrimitives().Skip(1).First(); PerfCounter.MeasureTime(() => { for (var i = 0; i < iterations; i++) { var serialized = XdrConverter.Serialize(original); var rehydrated = XdrConverter.Deserialize <PrimitiveTypes>(serialized); } }, () => { return($"{typeof(PrimitiveTypes).Name} serialization - {iterations} iterations."); }); }
public void XdrInheritanceSerializationPerformance() { var iterations = 1_000_000; var original = GeneratePrimitives().First(); var mammal = GenerateMammal(); PerfCounter.MeasureTime(() => { for (var i = 0; i < iterations; i++) { var serializedMammal = XdrConverter.Serialize(mammal); XdrConverter.Deserialize <Vertebrate>(serializedMammal); } }, () => { return($"Inheritance serialization - {iterations} iterations."); }); }