Пример #1
0
        public GpbBenchmarkState()
        {
            Marketdata = MarketDataIncrementalRefreshTrades.CreateBuilder();
            var input = new MemoryStream();

            GpbMarketDataBenchmark.Encode(Marketdata, input);
            In = input.ToArray();

            var outBuffer = new Byte[1024];

            Out = new MemoryStream(outBuffer);
        }
Пример #2
0
        public static long PerfTestDecode(int runNumber)
        {
            const int reps    = 1 * 1000 * 1000;
            var       state   = new GpbBenchmarkState();
            int       gcCount = GC.CollectionCount(0);

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

            for (int i = 0; i < reps; i++)
            {
                size = GpbMarketDataBenchmark.Decode(state.Marketdata, state.In);
            }
            var elapsedTicks = sw.ElapsedTicks;
            var avgOpLatency = (long)((elapsedTicks / (double)reps) * TicksToNanos);

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

            return(avgOpLatency);
        }