コード例 #1
0
        private static void MeasureLatency(int blockCount)
        {
            var entrySize = blockCount * XEvent.BlockSize;

            var engine = new XEngine(entrySize);

            engine.Start();

            var  beginIndex = 0;
            byte sequence   = 0;

            for (var i = 0; i < 10 * 1000 * 1000; i++)
            {
                var endIndex = beginIndex + XEvent.BlockSize - 1;

                using (var acquireScope = engine.AcquireEvent())
                {
                    var evt = acquireScope.Event;
                    for (var dataIndex = beginIndex; dataIndex <= endIndex; dataIndex++)
                    {
                        evt.Data[dataIndex] = sequence++;
                    }
                    evt.BeginOffset = beginIndex;
                    evt.EndOffset   = endIndex;
                    evt.Timestamp   = Stopwatch.GetTimestamp();
                }

                beginIndex = (beginIndex + XEvent.BlockSize) % entrySize;
            }

            engine.Stop();
            engine.Dispose();
        }
コード例 #2
0
        public static void MeasureEnqueue()
        {
            var engine = new XEngine();

            engine.Start();

            var stopwatch = new Stopwatch();

            for (int i = 0; i < 2; i++)
            {
                stopwatch.Restart();
                PublishTradingSignalV1(engine);
                stopwatch.Stop();
                var v1 = stopwatch.Elapsed;
                Console.WriteLine($"V1: {v1}");
                Thread.Sleep(200);

                stopwatch.Restart();
                PublishTradingSignalV2(engine);
                stopwatch.Stop();
                var v2 = stopwatch.Elapsed;
                Console.WriteLine($"V2: {v2}");
                Console.WriteLine($"Delta: {(v2.Ticks - v1.Ticks) / (double)v1.Ticks:P2}");
                Thread.Sleep(200);
            }

            engine.Stop();
        }
コード例 #3
0
        public static void PublisherMarketDataUpdates()
        {
            var engine = new XEngine();

            engine.Start();

            var publisher = new MarketDataPublisher2(engine, securityCount: 50);

            publisher.Run(1_000_000);
            Console.WriteLine($"Generated UpdateCount: {publisher.UpdateCount}");

            engine.Stop();
        }