Пример #1
0
        public async Task SingleDelayBlockTest(int delay)
        {
            var block = new DelayBlock <int>(delay);
            var t     = block.ProduceDataAsync(0, 1500).ContinueWith(x => block.Complete());
            var res   = await block.MeasureDataAsync();

            var delays = res.Delays[-1];

            OxyPlotExporter.ToPNG($"SingleDelayBlockTest_{delay}.png", $"target delay: {delay} ms", delays);
            _helper.AssertStats(delays, delay, delay + 10, skip: 3);
        }
Пример #2
0
        public async Task ParallelOneToOneDelayBlock(params int[] delays)
        {
            int N = delays.Length;

            Task <MeasurmentsData>[] measurments = new Task <MeasurmentsData> [N];
            for (int i = 0; i < N; i++)
            {
                var delay = delays[i];
                var block = new DelayBlock <int>(delay);
                measurments[i] = block.MeasureDataAsync();
                var t = block.ProduceDataAsync(i, 100).ContinueWith(x => block.Complete());
            }
            var measCollection = await Task.WhenAll(measurments);

            var statCollection = measCollection.Select(x => x.Delays[-1]).ToArray();

            OxyPlotExporter.ToPNG("ParallelOneToOneDelayBlock.png", $"target delays ({string.Join(", ", delays)}) ms", statCollection);
            foreach (var(delay, st) in delays.Zip(statCollection, (d, s) => (d, s)))
            {
                _helper.AssertStats(st, delay, delay * 0.1, skip: 10);
            }
        }