Beispiel #1
0
        public async Task ComparePerf(ThingToCheck whatToCheck)
        {
            await Task.FromResult(false);

            var iterations = 100000;
            var pipeline   = CreateFakePipeline(10).ToArray();
            var invoker    = GetInvoker(whatToCheck, pipeline);

            var stopwatch = Stopwatch.StartNew();

            for (var counter = 0; counter < iterations; counter++)
            {
                var headers          = new Dictionary <string, string>();
                var body             = new byte[] { 1, 2, 3 };
                var transportMessage = new TransportMessage(headers, body);
                var trannieContext   = new TransactionContext();
                var stepContext      = new IncomingStepContext(transportMessage, trannieContext);

                await invoker.Invoke(stepContext);
            }

            var elapsed = stopwatch.Elapsed;

            Console.WriteLine($"{iterations} iterations took {elapsed.TotalSeconds:0.0} s - that's {iterations / elapsed.TotalSeconds:0.0} iterations/s");
        }
        public async Task ComparePerf(ThingToCheck whatToCheck)
        {
#if NETSTANDARD1_3
            await Task.CompletedTask;
#else
            await Task.FromResult(false);
#endif

            var iterations = 100000;
            var pipeline   = CreateFakePipeline(10).ToArray();
            var invoker    = GetInvoker(whatToCheck, pipeline);

            var stopwatch = Stopwatch.StartNew();

            iterations.Times(() =>
            {
                var headers          = new Dictionary <string, string>();
                var body             = new byte[] { 1, 2, 3 };
                var transportMessage = new TransportMessage(headers, body);
                var trannieContext   = new TransactionContext();
                var stepContext      = new IncomingStepContext(transportMessage, trannieContext);
                invoker.Invoke(stepContext).Wait();
            });

            var elapsed = stopwatch.Elapsed;

            Console.WriteLine($"{iterations} iterations took {elapsed.TotalSeconds:0.0} s - that's {iterations / elapsed.TotalSeconds:0.0} iterations/s");
        }
Beispiel #3
0
        static IPipelineInvoker GetInvoker(ThingToCheck whatToCheck, IIncomingStep[] pipeline)
        {
            switch (whatToCheck)
            {
            case ThingToCheck.NoChange:
                return(new DefaultPipelineInvoker(new DefaultPipeline(initialIncomingSteps: pipeline)));

            case ThingToCheck.NewPipelineInvoker:
                return(new DefaultPipelineInvokerNew(new DefaultPipeline(initialIncomingSteps: pipeline)));

            default:
                throw new NotSupportedException("cannot do that yet");
            }
        }
 static IPipelineInvoker GetInvoker(ThingToCheck whatToCheck, IIncomingStep[] pipeline) => whatToCheck switch
 {