public void SimpleInitShutdownTest(int count)
 {
     for (int i = 0; i < count; i++)
     {
         MultiEventLoop.Initialize();
         MultiEventLoop.Shutdown();
     }
 }
        public void SimpleMultiEventLoopBenchmark()
        {
            const int TestSize = 30_000_000;

            MultiEventLoop.Initialize();
            try
            {
                // Warm-up
                var t = Task.Factory.StartNew(
                    () => { },
                    CancellationToken.None,
                    TaskCreationOptions.None,
                    MultiEventLoop.Scheduler);
                t.Wait();

                Stopwatch stopwatch = Stopwatch.StartNew();

                t = Task.Factory.StartNew(
                    () => EmptyLoop(TestSize),
                    CancellationToken.None,
                    TaskCreationOptions.None,
                    MultiEventLoop.Scheduler).Unwrap();
                t.Wait();

                stopwatch.Stop();
                double singleCoreSpeed = (TestSize * 1000.0) / stopwatch.ElapsedMilliseconds;
                TestContext.WriteLine($"single-thread:{singleCoreSpeed / 1000_000.0:F4} millions/sec");

                var tasks = new List <Task>();

                stopwatch = Stopwatch.StartNew();

                for (int i = 0; i < Environment.ProcessorCount; i++)
                {
                    t = Task.Factory.StartNew(
                        () => EmptyLoop(TestSize),
                        CancellationToken.None,
                        TaskCreationOptions.None,
                        MultiEventLoop.Scheduler).Unwrap();
                    tasks.Add(t);
                }

                foreach (var tsk in tasks)
                {
                    tsk.Wait();
                }

                stopwatch.Stop();
                double multiCoreSpeed = ((long)TestSize * tasks.Count * 1000.0) / stopwatch.ElapsedMilliseconds;
                TestContext.WriteLine(
                    $"{tasks.Count}-thread: {multiCoreSpeed / 1000_000.0:F4} millions/sec scalability={(multiCoreSpeed / (singleCoreSpeed * tasks.Count)) * 100.0:F3}%");
            }
            finally
            {
                MultiEventLoop.Shutdown();
            }
        }