public async Task StreamWinderPerformanceTest()
        {
            var source     = new CancellationTokenSource();
            var testStream = new InfiniteStream(TweetSamples.GetBinalyStreamSamples(), source.Token);
            var handler    = new PseudoStreamHandler();
            var received   = 0;

            source.CancelAfter(TimeSpan.FromSeconds(10));
            var receiveTask = StreamWinder.Run(testStream, content =>
            {
                UserStreamParser.ParseStreamLine(content, handler);
                received++;
            }, Timeout.InfiniteTimeSpan, source.Token);

            try
            {
                await receiveTask;
            }
            catch (OperationCanceledException)
            {
                // this is expected.
            }
            System.Diagnostics.Debug.WriteLine(received);
            // i promise myself the cadena engine can handle > 10K events per second.
            Debug.WriteLine("received: {0}", received);
            Debug.WriteLine("handler: statuses: {0} / events: {1}", handler.ReceivedStatuses, handler.ReceivedEvents);
            // Assert.IsTrue(received > 10000 * 10);
        }
 public async Task StreamWinderPerformanceTest()
 {
     var source = new CancellationTokenSource();
     var testStream = new InfiniteStream(TweetSamples.GetBinalyStreamSamples(), source.Token);
     var handler = new PseudoStreamHandler();
     var received = 0;
     source.CancelAfter(TimeSpan.FromSeconds(10));
     var receiveTask = StreamWinder.Run(testStream, content =>
     {
         UserStreamParser.ParseStreamLine(content, handler);
         received++;
     }, Timeout.InfiniteTimeSpan, source.Token);
     try
     {
         await receiveTask;
     }
     catch (OperationCanceledException)
     {
         // this is expected.
     }
     System.Diagnostics.Debug.WriteLine(received);
     // i promise myself the cadena engine can handle > 10K events per second.
     Debug.WriteLine("received: {0}", received);
     Debug.WriteLine("handler: statuses: {0} / events: {1}", handler.ReceivedStatuses, handler.ReceivedEvents);
     // Assert.IsTrue(received > 10000 * 10);
 }
        public void UserStreamParserPerformanceTest()
        {
            var workingset = Environment.WorkingSet;
            var parser = new JsonStringParser();
            // pre-work
            for (var i = 0; i < 100; i++)
            {
                foreach (var elem in TweetSamples.GetStreamSampleElements())
                {
                    parser.Parse(elem);
                }
            }

            var source = new CancellationTokenSource();
            var handler = new PseudoStreamHandler();
            var received = 0;
            source.CancelAfter(TimeSpan.FromSeconds(10));
            foreach (var content in TweetSamples.GetStreamSamples())
            {
                if (source.IsCancellationRequested) break;
                received++;
                UserStreamParser.ParseStreamLine(parser, content, handler);
            }
            var wsa = Environment.WorkingSet;
            TestContext.WriteLine("received: {0}", received);
            TestContext.WriteLine("handler: statuses: {0} / events: {1}", handler.ReceivedStatuses, handler.ReceivedEvents);
            TestContext.WriteLine("cache: {0} / {1}", parser.CacheCount(), parser.ALQCount());
            TestContext.WriteLine("workingset delta: {0}", wsa - workingset);
        }
        public void UserStreamParserPerformanceTest()
        {
            var workingset = Environment.WorkingSet;
            var parser     = new JsonStringParser();

            // pre-work
            for (var i = 0; i < 100; i++)
            {
                foreach (var elem in TweetSamples.GetStreamSampleElements())
                {
                    parser.Parse(elem);
                }
            }

            var source   = new CancellationTokenSource();
            var handler  = new PseudoStreamHandler();
            var received = 0;

            source.CancelAfter(TimeSpan.FromSeconds(10));
            foreach (var content in TweetSamples.GetStreamSamples())
            {
                if (source.IsCancellationRequested)
                {
                    break;
                }
                received++;
                UserStreamParser.ParseStreamLine(parser, content, handler);
            }
            var wsa = Environment.WorkingSet;

            TestContext.WriteLine("received: {0}", received);
            TestContext.WriteLine("handler: statuses: {0} / events: {1}", handler.ReceivedStatuses,
                                  handler.ReceivedEvents);
            TestContext.WriteLine("cache: {0} / {1}", parser.CacheCount(), parser.ALQCount());
            TestContext.WriteLine("workingset delta: {0}", wsa - workingset);
        }