Esempio n. 1
0
        public static long PerfTestDecode(int runNumber)
        {
            const int reps           = 10 * 1000 * 1000;
            var       state          = new BenchmarkState();
            var       marketDataSize = 0;

            var gcCount = GC.CollectionCount(0);

            var sw = Stopwatch.StartNew();

            for (int i = 0; i < reps; i++)
            {
                marketDataSize = MarketDataBenchmark.Decode(state.MessageHeader, state.MarketData, state.DecodeBuffer, state.BufferIndex);
            }

            var elapsedTicks = sw.ElapsedTicks;
            var avgOpLatency = (long)((elapsedTicks / (double)reps) * TicksToNanos);

            Console.WriteLine("[{0}/Decode/SBE] - {1}(ns) average latency - message size: {2} - GC count: {3}",
                              runNumber,
                              avgOpLatency,
                              marketDataSize + MessageHeader.Size,
                              GC.CollectionCount(0) - gcCount);

            return(avgOpLatency);
        }
Esempio n. 2
0
 public BenchmarkState()
 {
     _encodeBuffer = new DirectBuffer(_eBuffer);
     _decodeBuffer = new DirectBuffer(_dBuffer);
     MarketDataBenchmark.Encode(_messageHeader, _marketData, _decodeBuffer, BufferIndex);
 }