private async Task Benchmark()
        {
            Algorithm currentAlgorithm = null;

            while (_benchmarkAlgorithmQueue.Count > 0)
            {
                try
                {
                    if (_stopBenchmark.IsCancellationRequested)
                    {
                        break;
                    }
                    currentAlgorithm = _benchmarkAlgorithmQueue.Dequeue();
                    _benchmarkForm.AddToStatusCheck(Device, currentAlgorithm);
                    await BenchmarkAlgorithm(currentAlgorithm);

                    if (_stopBenchmark.IsCancellationRequested)
                    {
                        break;
                    }
                    _benchmarkForm.StepUpBenchmarkStepProgress();
                    ConfigManager.CommitBenchmarksForDevice(Device);
                }
                catch (Exception e)
                {
                    Helpers.ConsolePrint($"BenchmarkHandler-{Device.GetFullName()}", $"Exception {e}");
                }
            }
            currentAlgorithm?.ClearBenchmarkPending();
            // don't show unbenchmarked algos if user canceled
            if (_stopBenchmark.IsCancellationRequested)
            {
                return;
            }
            _benchmarkForm.EndBenchmarkForDevice(Device, _benchmarkFailedAlgo.Count > 0);
        }
        private async void Benchmark()
        {
            while (_benchmarkAlgorithmQueue.Count > 0)
            {
                if (_stopBenchmark.IsCancellationRequested)
                {
                    break;
                }

                _currentAlgorithm = _benchmarkAlgorithmQueue.Dequeue();
                _benchmarkForm.AddToStatusCheck(Device, _currentAlgorithm);
                if (_currentAlgorithm is PluginAlgorithm pAlgo)
                {
                    await BenchmarkPluginAlgorithm();
                }
                else
                {
                    await BenchmarkAlgorithm();
                }
                _benchmarkForm.StepUpBenchmarkStepProgress();
            }
            // if we get here we are finished
            EndBenchmark();
        }
        private void NextBenchmark()
        {
            ++_benchmarkCurrentIndex;
            if (_benchmarkCurrentIndex > 0)
            {
                _benchmarkForm.StepUpBenchmarkStepProgress();
            }
            if (_benchmarkCurrentIndex >= _benchmarkAlgorithmsCount)
            {
                EndBenchmark();
                return;
            }

            if (_benchmarkAlgorithmQueue.Count > 0)
            {
                _currentAlgorithm = _benchmarkAlgorithmQueue.Dequeue();
            }

            if (Device != null && _currentAlgorithm != null)
            {
                _currentMiner = MinerFactory.CreateMiner(Device, _currentAlgorithm);
                if (_currentAlgorithm is DualAlgorithm dualAlgo && dualAlgo.TuningEnabled)
                {
                    dualAlgo.StartTuning();
                }
            }

            if (_currentMiner != null && _currentAlgorithm != null && Device != null)
            {
                _currentMiner.InitBenchmarkSetup(new MiningPair(Device, _currentAlgorithm));

                var time = ConfigManager.GeneralConfig.BenchmarkTimeLimits
                           .GetBenchamrktime(_performanceType, Device.DeviceGroupType);
                //currentConfig.TimeLimit = time;

                // dagger about 4 minutes
                //var showWaitTime = _currentAlgorithm.NiceHashID == AlgorithmType.DaggerHashimoto ? 4 * 60 : time;

                _benchmarkForm.AddToStatusCheck(Device, _currentAlgorithm);

                _currentMiner.BenchmarkStart(time, this);
                _powerHelper.Start();
            }
            else
            {
                NextBenchmark();
            }
        }
예제 #4
0
        private void NextBenchmark()
        {
            ++_benchmarkCurrentIndex;
            if (_benchmarkCurrentIndex > 0)
            {
                _benchmarkForm.StepUpBenchmarkStepProgress();
            }
            if (_benchmarkCurrentIndex >= _benchmarkAlgorithmsCount)
            {
                EndBenchmark();
                return;
            }

            if (_benchmarkAlgorithmQueue.Count > 0)
            {
                _currentAlgorithm = _benchmarkAlgorithmQueue.Dequeue();
            }

            if (Device != null && _currentAlgorithm != null)
            {
                _currentMiner = MinerFactory.CreateMiner(Device, _currentAlgorithm);

                /*
                 * if (_currentAlgorithm.MinerBaseType == MinerBaseType.XmrStak && _currentAlgorithm.NiceHashID == AlgorithmType.CryptoNight
                 *  && string.IsNullOrEmpty(_currentAlgorithm.ExtraLaunchParameters)
                 *  && _currentAlgorithm.ExtraLaunchParameters.Contains("enable_ht=true") == false) {
                 *  _cpuBenchmarkStatus = new CPUBenchmarkStatus(Globals.ThreadsPerCPU);
                 *  _currentAlgorithm.LessThreads = _cpuBenchmarkStatus.LessTreads;
                 * } else {
                 *  _cpuBenchmarkStatus = null;
                 * }
                 */
                _cpuBenchmarkStatus = null;

                if (_currentAlgorithm.MinerBaseType == MinerBaseType.Claymore &&
                    _currentAlgorithm.NiceHashID == AlgorithmType.Equihash &&
                    _currentAlgorithm.ExtraLaunchParameters != null &&
                    !_currentAlgorithm.ExtraLaunchParameters.Contains("-asm"))
                {
                    _claymoreZcashStatus = new ClaymoreZcashBenchHelper(_currentAlgorithm.ExtraLaunchParameters);
                    _currentAlgorithm.ExtraLaunchParameters = _claymoreZcashStatus.GetTestExtraParams();
                }
                else
                {
                    _claymoreZcashStatus = null;
                }

                if (_currentAlgorithm is DualAlgorithm dualAlgo && dualAlgo.TuningEnabled)
                {
                    dualAlgo.StartTuning();
                }
            }

            if (_currentMiner != null && _currentAlgorithm != null && Device != null)
            {
                _currentMiner.InitBenchmarkSetup(new MiningPair(Device, _currentAlgorithm));

                var time = ConfigManager.GeneralConfig.BenchmarkTimeLimits
                           .GetBenchamrktime(_performanceType, Device.DeviceGroupType);
                //currentConfig.TimeLimit = time;
                if (_cpuBenchmarkStatus != null)
                {
                    _cpuBenchmarkStatus.Time = time;
                }
                if (_claymoreZcashStatus != null)
                {
                    _claymoreZcashStatus.Time = time;
                }

                // dagger about 4 minutes
                //var showWaitTime = _currentAlgorithm.NiceHashID == AlgorithmType.DaggerHashimoto ? 4 * 60 : time;

                _benchmarkForm.AddToStatusCheck(Device, _currentAlgorithm);

                _currentMiner.BenchmarkStart(time, this);
                _powerHelper.Start();
            }
            else
            {
                NextBenchmark();
            }
        }