Exemplo n.º 1
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);
                algo.SetError(result.ErrorMessage);
                algo.ClearBenchmarkPending();
                BenchmarkManager.SetCurrentStatus(Device, algo, result.ErrorMessage);
            }
        }
Exemplo n.º 2
0
        private async Task Benchmark()
        {
            AlgorithmContainer currentAlgorithm = null;

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

                    currentAlgorithm.InBenchmark = false;
                    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);
        }
Exemplo n.º 3
0
        } = BenchmarkPerformanceType.Standard;                                                             // TODO TEMP

        private async Task <object> BenchmarkAlgorithm(AlgorithmContainer algo, CancellationToken stop)
        {
            if (algo == null)
            {
                Logger.Error("BenchmarkingComputeDeviceHandler.BenchmarkNextAlgorithm", $"TakeNextAlgorithm returned null");
                return(false);
            }

            bool ret         = false;
            var  miningPairs = new List <MiningPair> {
                algo.ToMiningPair()
            };

            try
            {
                algo.IsBenchmarking = true;
                using (var powerHelper = new PowerHelper(algo.ComputeDevice))
                {
                    var plugin = algo.PluginContainer;
                    var miner  = plugin.CreateMiner();

                    GPUProfileManager.Instance.Start(miningPairs);
                    miner.InitMiningPairs(miningPairs);
                    // fill service since the benchmark might be online. DemoUser.BTC must be used
                    miner.InitMiningLocationAndUsername("auto", DemoUser.BTC);
                    powerHelper.Start();
                    algo.ComputeDevice.State = DeviceState.Benchmarking;
                    var result = await miner.StartBenchmark(stop, BenchmarkManagerState.Instance.SelectedBenchmarkType);

                    GPUProfileManager.Instance.Stop(miningPairs);
                    if (stop.IsCancellationRequested)
                    {
                        return(false);
                    }

                    algo.IsReBenchmark = false;
                    var power = powerHelper.Stop();
                    ret = result.Success || result.AlgorithmTypeSpeeds?.Count > 0;
                    if (ret)
                    {
                        algo.Speeds     = result.AlgorithmTypeSpeeds.Select(ats => ats.speed).ToList();
                        algo.PowerUsage = power;
                        ConfigManager.CommitBenchmarksForDevice(algo.ComputeDevice);
                    }
                    else
                    {
                        // mark it as failed
                        algo.LastBenchmarkingFailed = true;
                        algo.SetBenchmarkError(result.ErrorMessage);
                    }
                }
            }
            finally
            {
                GPUProfileManager.Instance.Stop(miningPairs);
                algo.ClearBenchmarkPending();
                algo.IsBenchmarking = false;
            }

            return(ret);
        }
Exemplo n.º 4
0
        } = BenchmarkPerformanceType.Standard;                                                             // TODO TEMP

        private async Task <object> BenchmarkAlgorithm(AlgorithmContainer algo, CancellationToken stop)
        {
            if (algo == null)
            {
                Logger.Error("BenchmarkingComputeDeviceHandler.BenchmarkNextAlgorithm", $"TakeNextAlgorithm returned null");
                return(false);
            }

            // TODO here you got shity state
            var miningLocation = StratumService.Instance.SelectedOrFallbackServiceLocationCode().miningLocationCode;

            // TODO hidden issue here if our market is not available we will not be able to execute benchmarks
            // unable to benchmark service locations are not operational
            if (miningLocation == null)
            {
                return(false);
            }


            bool ret         = false;
            var  miningPairs = new List <MiningPair> {
                algo.ToMiningPair()
            };

            try
            {
                algo.IsBenchmarking = true;
                using (var powerHelper = new PowerHelper(algo.ComputeDevice))
                {
                    var plugin = algo.PluginContainer;
                    var miner  = plugin.CreateMiner();

                    // check ethlargement
                    EthlargementIntegratedPlugin.Instance.Start(miningPairs);
                    miner.InitMiningPairs(miningPairs);
                    // fill service since the benchmark might be online. DemoUser.BTC must be used
                    miner.InitMiningLocationAndUsername(miningLocation, DemoUser.BTC);
                    powerHelper.Start();
                    algo.ComputeDevice.State = DeviceState.Benchmarking;
                    var result = await miner.StartBenchmark(stop, PerformanceType);

                    EthlargementIntegratedPlugin.Instance.Stop(miningPairs);
                    if (stop.IsCancellationRequested)
                    {
                        return(false);
                    }

                    algo.IsReBenchmark = false;
                    var power = powerHelper.Stop();
                    ret = result.Success || result.AlgorithmTypeSpeeds?.Count > 0;
                    if (ret)
                    {
                        algo.Speeds     = result.AlgorithmTypeSpeeds.Select(ats => ats.speed).ToList();
                        algo.PowerUsage = power;
                        ConfigManager.CommitBenchmarksForDevice(algo.ComputeDevice);
                    }
                    else
                    {
                        // mark it as failed
                        algo.LastBenchmarkingFailed = true;
                        algo.SetBenchmarkError(result.ErrorMessage);
                    }
                }
            }
            finally
            {
                EthlargementIntegratedPlugin.Instance.Stop(miningPairs);
                algo.ClearBenchmarkPending();
                algo.IsBenchmarking = false;
            }

            return(ret);
        }