Beispiel #1
0
        public async override Task <BenchmarkResult> StartBenchmark(CancellationToken stop, BenchmarkPerformanceType benchmarkType = BenchmarkPerformanceType.Standard)
        {
            //only 60s mark is available
            var benchmarkTime     = 60; // in seconds
            var commandLine       = $"-a {AlgoName} --benchmark -d {_devices} --multiple-instance {_extraLaunchParameters}";
            var binPathBinCwdPair = GetBinAndCwdPaths();
            var binPath           = binPathBinCwdPair.Item1;
            var binCwd            = binPathBinCwdPair.Item2;

            Logger.Info(_logGroup, $"Benchmarking started with command: {commandLine}");
            var bp = new BenchmarkProcess(binPath, binCwd, commandLine, GetEnvironmentVariables());

            var benchHashResult = 0d;

            bp.CheckData = (string data) =>
            {
                var hashrateFoundPair = BenchmarkHelpers.TryGetHashrateAfter(data, "60s:");
                var hashrate          = hashrateFoundPair.Item1;
                var found             = hashrateFoundPair.Item2;

                if (found)
                {
                    benchHashResult = hashrate * (1 - DevFee * 0.01);
                }

                return(new BenchmarkResult
                {
                    AlgorithmTypeSpeeds = new List <AlgorithmTypeSpeedPair> {
                        new AlgorithmTypeSpeedPair(_algorithmType, benchHashResult)
                    },
                    Success = found
                });
            };

            // always add 10second extra
            var benchmarkTimeout = TimeSpan.FromSeconds(10 + benchmarkTime);
            var benchmarkWait    = TimeSpan.FromMilliseconds(500);
            var t = MinerToolkit.WaitBenchmarkResult(bp, benchmarkTimeout, benchmarkWait, stop);

            return(await t);
        }
Beispiel #2
0
        public async override Task <BenchmarkResult> StartBenchmark(CancellationToken stop, BenchmarkPerformanceType benchmarkType = BenchmarkPerformanceType.Standard)
        {
            var benchmarkTime = 60; // in seconds

            switch (benchmarkType)
            {
            case BenchmarkPerformanceType.Precise:
                benchmarkTime = 120;
                break;

            default:
                benchmarkTime = 60;
                break;
            }


            var commandLine       = $"-a {AlgoName} --benchmark -d {_devices} --multiple-instance {_extraLaunchParameters}";
            var binPathBinCwdPair = GetBinAndCwdPaths();
            var binPath           = binPathBinCwdPair.Item1;
            var binCwd            = binPathBinCwdPair.Item2;

            Logger.Info(_logGroup, $"Benchmarking started with command: {commandLine}");
            var bp = new BenchmarkProcess(binPath, binCwd, commandLine, GetEnvironmentVariables());

            var benchHashResult = 0d;

            bp.CheckData = (string data) =>
            {
                if (!data.Contains("hashrate:"))
                {
                    return(new BenchmarkResult {
                        AlgorithmTypeSpeeds = new List <AlgorithmTypeSpeedPair> {
                            new AlgorithmTypeSpeedPair(_algorithmType, 0d)
                        }, Success = false
                    });
                }
                var hashrateFoundPair = BenchmarkHelpers.TryGetHashrateAfter(data, "60s:");
                var hashrate          = hashrateFoundPair.Item1;

                // TODO temporary fix for N/A speeds at 60s mark... will be fixed when developer fixes benchmarking
                if (hashrate == 0)
                {
                    hashrateFoundPair = BenchmarkHelpers.TryGetHashrateAfter(data, "10s:");
                }
                hashrate = hashrateFoundPair.Item1;
                var found = hashrateFoundPair.Item2;

                if (!found)
                {
                    return new BenchmarkResult {
                               AlgorithmTypeSpeeds = new List <AlgorithmTypeSpeedPair> {
                                   new AlgorithmTypeSpeedPair(_algorithmType, benchHashResult)
                               }, Success = false
                    }
                }
                ;

                benchHashResult = hashrate * (1 - DevFee * 0.01);

                return(new BenchmarkResult
                {
                    AlgorithmTypeSpeeds = new List <AlgorithmTypeSpeedPair> {
                        new AlgorithmTypeSpeedPair(_algorithmType, benchHashResult)
                    },
                    Success = found
                });
            };

            // always add 10second extra
            var benchmarkTimeout = TimeSpan.FromSeconds(10 + benchmarkTime);
            var benchmarkWait    = TimeSpan.FromMilliseconds(500);
            var t = MinerToolkit.WaitBenchmarkResult(bp, benchmarkTimeout, benchmarkWait, stop);

            return(await t);
        }