Inheritance: PublicFeed
Example #1
0
        public void TimeReceiving1MillionMessages()
        {
            const string format = @"{{""cmd"":""depth"",""args"":{{""i"":""{0}"",""m"":30,""t"":""depth"",""tick_timestamp"":""2010-01-22 16:22:06"",""bid1"":0.00,""bid_volume1"":0,""ask1"":120.00,""ask_volume1"":200,""bid2"":0.00,""bid_volume2"":0,""ask2"":0.00,""ask_volume2"":0,""bid3"":0.00,""bid_volume3"":0,""ask3"":0.00,""ask_volume3"":0,""bid4"":0.00,""bid_volume4"":0,""ask4"":0.00,""ask_volume4"":0,""bid5"":0.00,""bid_volume5"":0,""ask5"":0.00,""ask_volume5"":0}}}}";
            const int n = 1000000;
            var messages = new string[n];
            for (int i = 0; i < n; i++)
            {
                messages[i] = string.Format(format, i);
            }
            var feed = new PublicFeedStub();
            var args = new List<DepthTick>(n);
            Stopwatch stopwatch = Stopwatch.StartNew();
            feed.RecievedDepth += (_, e) => args.Add(e);

            for (int i = 0; i < n; i++)
            {
                feed.ReceiveMessage(messages[i]);
            }
            Console.WriteLine("This took {0} ms {1}", stopwatch.ElapsedMilliseconds, DateTime.Now.ToShortDateString());
            // This took 24152 ms 2014-09-14
            Assert.AreEqual(n, args.Count);
        }
Example #2
0
 public void SetUp()
 {
     _feed = new PublicFeedStub();
     _exceptions = new List<ExceptionEventArgs>();
     _feed.Exception += (_, e) => _exceptions.Add(e);
 }