コード例 #1
0
 public async Task HeavyMonitorLockUC(BenchInfo info, IPerfCounterCollectorUC perfColletor, TimeSpan ts, int spin, int threads)
 {
                 #pragma warning disable 618
     ILockUC Lock = new MonitorLockUC();
                 #pragma warning restore 618
     await GeneralBenchmark(perfColletor, info.Name, threads, i => Lock, (i, perfCntr, sync) => new BenchInstance[] { new SimpleLockWorker(perfCntr, Lock, ts, spin, string.Empty) });
 }
コード例 #2
0
        public async Task NeighborMonitorLockUC(BenchInfo info, IPerfCounterCollectorUC perfColletor, TimeSpan ts, int spin, int threadPairs)
        {
                        #pragma warning disable 618
            await GeneralBenchmark(perfColletor, info.Name, threadPairs, i => new MonitorLockUC(), (i, perfCntr, sync) => new BenchInstance[] { new SimpleLockWorker(perfCntr, sync, ts, spin, $"A{i}"), new SimpleLockWorker(perfCntr, sync, ts, spin, $"B{i}") });

                        #pragma warning restore 618
        }
コード例 #3
0
        public static async Task DataCollecor(IPerfCounterCollectorUC perfCollector)
        {
            Task recorder = Task.Run(FileRecorder);

            WriteContext = msg =>
            {
                NotificationQueue.Enqueue(priority.top, msg);
                System.Console.WriteLine(msg ?? string.Empty);
            };

            Process.GetCurrentProcess().ProcessName.WriteLine();
            "Enjoy! ipavlu 2017".WriteLine();

            await Task.Delay(2000);

            BenchInfo sequential = Tests[0.ToString()];
            await sequential.Test(sequential, perfCollector, BenchInfo.TestingTimeSpan, 1000000);

            string.Empty.WriteLine();
            string.Empty.WriteLine();

            double steps   = 6;
            double logStep = Math.Pow(2.0, 1.0 / steps);

            int[] spins =
                Enumerable
                .Range(0, 101)
                .Select(i => (int)(1000.0 * Math.Pow(logStep, i)))
                .ToArray()
            ;

            foreach (int spin in spins)
            {
                foreach (BenchInfo info in Tests.Where(x => x.Value.CollectorSupport).Select(x => x.Value))
                {
                    await Task.Delay(2000);

                    await info.Test(info, perfCollector, BenchInfo.TestingTimeSpan, spin);

                    string.Empty.WriteLine();
                    string.Empty.WriteLine();
                }
            }

            ((string)null).WriteLine();
            await recorder;

            WriteContext = System.Console.WriteLine;
        }
コード例 #4
0
        public async Task HeavyConcurrentQueue(BenchInfo info, IPerfCounterCollectorUC perfColletor, TimeSpan ts, int spin, int threadPairs)
        {
            ConcurrentQueue <object> queue = new ConcurrentQueue <object>();

            await GeneralBenchmark(perfColletor, info.Name, threadPairs, i => string.Empty, (i, perfCntr, sync) => new BenchInstance[] { new ConcurrentQueueWriterWorker(queue, perfCntr, ts, spin, $"W{i}"), new ConcurrentQueueWriterWorker(queue, perfCntr, ts, spin, $"R{i}") });
        }
コード例 #5
0
 public async Task NeighborTicketSpinLockUC(BenchInfo info, IPerfCounterCollectorUC perfColletor, TimeSpan ts, int spin, int threadPairs)
 {
     await GeneralBenchmark(perfColletor, info.Name, threadPairs, i => new TicketSpinLockUC(), (i, perfCntr, sync) => new BenchInstance[] { new SimpleLockWorker(perfCntr, sync, ts, spin, $"A{i}"), new SimpleLockWorker(perfCntr, sync, ts, spin, $"B{i}") });
 }
コード例 #6
0
        public async Task HeavyAsyncLockUC(BenchInfo info, IPerfCounterCollectorUC perfColletor, TimeSpan ts, int spin, int threads)
        {
            IAsyncLockUC Lock = new AsyncLockUC();

            await GeneralBenchmark(perfColletor, info.Name, threads, i => Lock, (i, perfCntr, sync) => new BenchInstance[] { new AsyncLockWorker(perfCntr, Lock, ts, spin, string.Empty), });
        }
コード例 #7
0
 public async Task HeavySequential(BenchInfo info, IPerfCounterCollectorUC perfColletor, TimeSpan ts, int spin, int threads)
 {
     await GeneralBenchmark(perfColletor, info.Name, threads, i => new object(), (i, perfCntr, sync) => new BenchInstance[] { new SequentialWorker(perfCntr, ts, spin, string.Empty) });
 }
コード例 #8
0
 public Task Test(BenchInfo bi, IPerfCounterCollectorUC perfCollector, TimeSpan ts, int spins) => Task?.Invoke(bi, perfCollector, ts, spins) ?? System.Threading.Tasks.Task.CompletedTask;