Пример #1
0
        public void CanMeasureTimeSpentInSteps()
        {
            var stats    = new PipelineStepProfilerStats();
            var pipeline = new DefaultPipeline()
                           .OnReceive(new Step300())
                           .OnReceive(new Step100())
                           .OnReceive(new Step200());

            var profiler = new PipelineStepProfiler(pipeline, stats);

            var receivePipeline  = profiler.ReceivePipeline();
            var invoker          = new DefaultPipelineInvoker();
            var transportMessage = new TransportMessage(new Dictionary <string, string>(), new byte[0]);

            using (new DefaultTransactionContextScope())
            {
                var stepContext = new IncomingStepContext(transportMessage, AmbientTransactionContext.Current);

                invoker.Invoke(stepContext, receivePipeline).Wait();

                var stepStats = stats.GetStats();

                Console.WriteLine(string.Join(Environment.NewLine, stepStats));
            }
        }
Пример #2
0
        public async Task InvokesInOrder()
        {
            var invoker = new DefaultPipelineInvoker();

            var stepContext = new IncomingStepContext(new TransportMessage(new Dictionary <string, string>(), new byte[0]), null);

            await invoker.Invoke(stepContext, new IIncomingStep[]
            {
                new NamedStep("first"),
                new NamedStep("second"),
                new NamedStep("third"),
            });

            Console.WriteLine(string.Join(Environment.NewLine, stepContext.Load <List <string> >()));
        }
Пример #3
0
        public void CheckTiming()
        {
            var invoker = new DefaultPipelineInvoker();

            var stopwatch = Stopwatch.StartNew();

            1000000.Times(() =>
            {
                var stepContext = new IncomingStepContext(new TransportMessage(new Dictionary <string, string>(), new byte[0]), GetFakeTransactionContext());

                var pipeline = Enumerable.Range(0, 15)
                               .Select(stepNumber => new NamedStep(string.Format("step {0}", stepNumber)))
                               .ToArray();

                invoker.Invoke(stepContext, pipeline).Wait();
            });

            Console.WriteLine("Execution took {0:0.0} s", stopwatch.Elapsed.TotalSeconds);
        }