예제 #1
0
파일: Program.cs 프로젝트: wushian/Stacks
        static void RunSingleExecutor()
        {
            var test = new SingleExecutor(1000000, () => new ActionBlockExecutor());
            var stats = Benchmark.Measure(test.Run, 5);

            Console.WriteLine("Action block (ctx) executor: " + stats);
            Console.WriteLine("Action block (ctx) time per msg: " + stats.GetAverateTimePerActionNs(1000000).ToString() + "ns");

            test = new SingleExecutor(1000000, () => new ActionBlockExecutor("", new ActionBlockExecutorSettings() { SupportSynchronizationContext = false }));
            stats = Benchmark.Measure(test.Run, 5);

            Console.WriteLine("Action block (no ctx) executor: " + stats);
            Console.WriteLine("Action block (no ctx) time per msg: " + stats.GetAverateTimePerActionNs(1000000).ToString() + "ns");

            test = new SingleExecutor(1000000, () => new BusyWaitExecutor());
            stats = Benchmark.Measure(test.Run, 5);

            Console.WriteLine("Yielding executor: " + stats);
            Console.WriteLine("Yielding time per msg: " + stats.GetAverateTimePerActionNs(1000000).ToString() + "ns");
        }
예제 #2
0
        static void RunSingleExecutor()
        {
            var test  = new SingleExecutor(1000000, () => new ActionBlockExecutor());
            var stats = Benchmark.Measure(test.Run, 5);

            Console.WriteLine("Action block (ctx) executor: " + stats);
            Console.WriteLine("Action block (ctx) time per msg: " + stats.GetAverateTimePerActionNs(1000000).ToString() + "ns");

            test = new SingleExecutor(1000000, () => new ActionBlockExecutor("", new ActionBlockExecutorSettings()
            {
                SupportSynchronizationContext = false
            }));
            stats = Benchmark.Measure(test.Run, 5);

            Console.WriteLine("Action block (no ctx) executor: " + stats);
            Console.WriteLine("Action block (no ctx) time per msg: " + stats.GetAverateTimePerActionNs(1000000).ToString() + "ns");


            test  = new SingleExecutor(1000000, () => new BusyWaitExecutor());
            stats = Benchmark.Measure(test.Run, 5);

            Console.WriteLine("Yielding executor: " + stats);
            Console.WriteLine("Yielding time per msg: " + stats.GetAverateTimePerActionNs(1000000).ToString() + "ns");
        }