示例#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");
        }