Esempio n. 1
0
        public void Copy_PassAsArgumentAndReturn_FromValueTaskSource()
        {
            ValueTask <int> vt = new ValueTask <int>(ManualResetValueTaskSource.Completed(42), 0);

            foreach (BenchmarkIteration iteration in Benchmark.Iterations)
            {
                long iters = Benchmark.InnerIterationCount;
                using (iteration.StartMeasurement())
                {
                    for (long i = 0; i < iters; i++)
                    {
                        vt = ReturnValueTask(vt);
                    }
                }
            }
        }
Esempio n. 2
0
        public async Task Await_FromCompletedValueTaskSource()
        {
            ValueTask <int> vt = new ValueTask <int>(ManualResetValueTaskSource.Completed <int>(42), 0);

            foreach (BenchmarkIteration iteration in Benchmark.Iterations)
            {
                long iters = Benchmark.InnerIterationCount;
                using (iteration.StartMeasurement())
                {
                    for (long i = 0; i < iters; i++)
                    {
                        await vt;
                    }
                }
            }
        }
Esempio n. 3
0
        public async Task CreateAndAwait_FromCompletedValueTaskSource_ConfigureAwait()
        {
            IValueTaskSource <int> vts = ManualResetValueTaskSource.Completed(42);

            foreach (BenchmarkIteration iteration in Benchmark.Iterations)
            {
                long iters = Benchmark.InnerIterationCount;
                using (iteration.StartMeasurement())
                {
                    for (long i = 0; i < iters; i++)
                    {
                        await new ValueTask <int>(vts, 0).ConfigureAwait(false);
                    }
                }
            }
        }