Exemplo n.º 1
0
        private async Task BenchmarkAlgorithm(AlgorithmContainer algo, CancellationToken stop)
        {
            using (var powerHelper = new PowerHelper(algo.ComputeDevice))
            {
                var plugin     = algo.PluginContainer;
                var miner      = plugin.CreateMiner();
                var miningPair = new MinerPlugin.MiningPair
                {
                    Device    = algo.ComputeDevice.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.Instance.SelectedServiceLocation, DemoUser.BTC);
                powerHelper.Start();
                algo.ComputeDevice.State = DeviceState.Benchmarking;
                var result = await miner.StartBenchmark(stop, PerformanceType);

                if (stop.IsCancellationRequested)
                {
                    return;
                }

                algo.IsReBenchmark = false;
                //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
                    BenchmarkManager.SetCurrentStatus(algo.ComputeDevice, algo, "");
                    ConfigManager.CommitBenchmarksForDevice(algo.ComputeDevice);
                }
                else
                {
                    // mark it as failed
                    algo.LastBenchmarkingFailed = true;
                    // add new failed list
                    _benchmarkFailedAlgo.Add(algo.AlgorithmName);
                    algo.SetBenchmarkError(result.ErrorMessage);
                    BenchmarkManager.SetCurrentStatus(algo.ComputeDevice, algo, result.ErrorMessage);
                }
            }
        }
Exemplo n.º 2
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);
            }
        }