Пример #1
0
        async Task GenerateSamples()
        {
            Busy = true;
            var samplerParams = GetSorterSamplerParams(KeyCount.Value);

            _stopwatch.Reset();
            _stopwatch.Start();
            _cancellationTokenSource = new CancellationTokenSource();

            var rando  = Rando.Fast(Seed.Value);
            var inputs = Enumerable.Range(0, 10000).Select(t => rando.NextInt());

            IEnumerativeBackgroundWorker <int, SorterSamplerResults> ibw = EnumerativeBackgroundWorker.Make
                                                                           (
                inputs: inputs,
                mapper: (i, c) =>
            {
                var sorterSamplerResults = SorterRandomSampler.SorterSampler(
                    keyCount: KeyCount.Value,
                    switchCount: samplerParams.SwitchCount,
                    histogramMin: samplerParams.HistogramMin,
                    histogramMax: samplerParams.HistogramMax,
                    seed: i,
                    repCount: ReportFrequency.Value,
                    lowRangeMax: LowRangeMax.Value,
                    highRangeMin: HighRangeMin.Value,
                    cancellationToken: _cancellationTokenSource.Token
                    );

                if (sorterSamplerResults.WasCancelled)
                {
                    return(IterationResult.Make(default(SorterSamplerResults), ProgressStatus.StepIncomplete));
                }

                return(IterationResult.Make(sorterSamplerResults, ProgressStatus.StepComplete));
            }
                                                                           );

            ibw.OnIterationResult.Subscribe(UpdateSorterSamplerResults);
            await ibw.Start(_cancellationTokenSource);


            Busy = false;
            _stopwatch.Stop();
            CommandManager.InvalidateRequerySuggested();
        }
Пример #2
0
 protected void OnResetCommand()
 {
     _updateSubscription.Dispose();
     _sorterBackgroundWorker = null;
     SorterEvalGridVm.SorterEvalVms.Clear();
 }