Ejemplo n.º 1
0
        public static long PerfTestEncode(int runNumber)
        {
            const int reps    = 10 * 1000 * 1000;
            var       state   = new BenchmarkState();
            var       gcCount = GC.CollectionCount(0);

            var sw   = Stopwatch.StartNew();
            var size = 0;

            for (int i = 0; i < reps; i++)
            {
                size = MarketDataBenchmark.Encode(state.MessageHeader, state.MarketData, state.EncodeBuffer, state.BufferIndex);
            }

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

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

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