private async Task BenchmarkAlgorithm(Algorithm algo)
 {
     BenchmarkManager.AddToStatusCheck(Device, algo);
     if (algo is PluginAlgorithm pAlgo)
     {
         await BenchmarkPluginAlgorithm(pAlgo);
     }
 }
        private async Task BenchmarkAlgorithm(Algorithm algo)
        {
            var currentMiner = MinerFactory.CreateMinerForBenchmark(algo);

            if (currentMiner == null)
            {
                return;
            }

            BenchmarkManager.AddToStatusCheck(Device, algo);
            if (algo is PluginAlgorithm pAlgo)
            {
                await BenchmarkPluginAlgorithm(pAlgo);
            }
        }
Esempio n. 3
0
        private async Task BenchmarkAlgorithm(AlgorithmContainer algo)
        {
            BenchmarkManager.AddToStatusCheck(Device, algo);
            var plugin     = algo.PluginContainer;
            var miner      = plugin.CreateMiner();
            var miningPair = new MinerPlugin.MiningPair
            {
                Device    = Device.BaseDevice,
                Algorithm = algo.Algorithm
            };
            // check ethlargement
            var miningPairs = new List <MinerPlugin.MiningPair> {
                miningPair
            };

            EthlargementIntegratedPlugin.Instance.Start(miningPairs);
            miner.InitMiningPairs(miningPairs);
            // fill service since the benchmark might be online. DemoUser.BTC must be used
            miner.InitMiningLocationAndUsername(StratumService.SelectedServiceLocation, DemoUser.BTC);
            _powerHelper.Start();
            var result = await miner.StartBenchmark(_stopBenchmark.Token, _performanceType);

            //EthlargementIntegratedPlugin.Instance.Stop(miningPairs); // TODO check stopping
            var power = _powerHelper.Stop();

            if (result.Success || result.AlgorithmTypeSpeeds?.Count > 0)
            {
                var ids    = result.AlgorithmTypeSpeeds.Select(ats => ats.AlgorithmType).ToList();
                var speeds = result.AlgorithmTypeSpeeds.Select(ats => ats.Speed).ToList();
                algo.Speeds     = speeds;
                algo.PowerUsage = power;
                // set status to empty string it will return speed
                algo.ClearBenchmarkPending();
                BenchmarkManager.SetCurrentStatus(Device, algo, "");
            }
            else
            {
                // add new failed list
                _benchmarkFailedAlgo.Add(algo.AlgorithmName);
                BenchmarkManager.SetCurrentStatus(Device, algo, result.ErrorMessage);
            }
        }
Esempio n. 4
0
        private async Task Benchmark()
        {
            AlgorithmContainer currentAlgorithm = null;

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

                    await Task.Delay(ConfigManager.GeneralConfig.MinerRestartDelayMS);

                    if (_stopBenchmark.IsCancellationRequested)
                    {
                        break;
                    }
                    currentAlgorithm.IsReBenchmark = false;
                    BenchmarkManager.StepUpBenchmarkStepProgress();
                    ConfigManager.CommitBenchmarksForDevice(Device);
                }
                catch (Exception e)
                {
                    Logger.Error("BenchmarkHandler", $"Exception occurred in benchmark task: {e.Message}");
                }
            }
            currentAlgorithm?.ClearBenchmarkPending();
            var cancel = _stopBenchmark.IsCancellationRequested;
            // don't show unbenchmarked algos if user canceled
            var showFailed  = _benchmarkFailedAlgo.Count > 0 && !cancel;
            var startMining = _startMiningAfterBenchmark && !cancel;

            BenchmarkManager.EndBenchmarkForDevice(Device, showFailed, startMining);
        }