diff --git a/src/App.cpp b/src/App.cpp index f1dcdfce..e0b735ca 100644 --- a/src/App.cpp +++ b/src/App.cpp @@ -135,8 +135,9 @@ int App::exec() Workers::setListener(&benchmark); // register benchmark as job reault listener to compute hashrates there // write text before first benchmark round Log::i()->text(m_controller->config()->isColors() - ? GREEN_BOLD(" >>>>> ") WHITE_BOLD("STARTING ALGO PERFORMANCE CALIBRATION") - : " >>>>> STARTING ALGO PERFORMANCE CALIBRATION" + ? GREEN_BOLD(" >>>>> ") WHITE_BOLD("STARTING ALGO PERFORMANCE CALIBRATION (with %i seconds round)") + : " >>>>> STARTING ALGO PERFORMANCE CALIBRATION (with %i seconds round)", + m_controller->config()->calibrateAlgoTime() ); benchmark.start_perf_bench(xmrig::PerfAlgo::PA_CN); // start benchmarking from first PerfAlgo in the list } else { diff --git a/src/common/config/CommonConfig.cpp b/src/common/config/CommonConfig.cpp index f79c492a..0f0ef541 100644 --- a/src/common/config/CommonConfig.cpp +++ b/src/common/config/CommonConfig.cpp @@ -47,6 +47,7 @@ xmrig::CommonConfig::CommonConfig() : m_colors(true), m_dryRun(false), m_calibrateAlgo(false), + m_calibrateAlgoTime(60), m_saveConfig(false), m_syslog(false), @@ -357,6 +358,12 @@ bool xmrig::CommonConfig::parseInt(int key, int arg) } break; + case CalibrateAlgoTimeKey: /* --calibrate-algo-time */ + if (arg >= 5 && arg <= 3600) { + m_calibrateAlgoTime = arg; + } + break; + default: break; } diff --git a/src/common/config/CommonConfig.h b/src/common/config/CommonConfig.h index 17bab1d8..6ab0d42b 100644 --- a/src/common/config/CommonConfig.h +++ b/src/common/config/CommonConfig.h @@ -50,6 +50,7 @@ public: inline bool isColors() const { return m_colors; } inline bool isDryRun() const { return m_dryRun; } inline bool isCalibrateAlgo() const { return m_calibrateAlgo; } + inline int calibrateAlgoTime() const { return m_calibrateAlgoTime; } inline bool isSaveConfig() const { return m_saveConfig; } inline bool isSyslog() const { return m_syslog; } inline const char *apiToken() const { return m_apiToken.data(); } @@ -91,6 +92,7 @@ protected: bool m_colors; bool m_dryRun; bool m_calibrateAlgo; + int m_calibrateAlgoTime; bool m_saveConfig; bool m_syslog; bool m_watch; diff --git a/src/common/interfaces/IConfig.h b/src/common/interfaces/IConfig.h index cd24ac90..73fa73d5 100644 --- a/src/common/interfaces/IConfig.h +++ b/src/common/interfaces/IConfig.h @@ -69,7 +69,8 @@ public: NicehashKey = 1006, PrintTimeKey = 1007, CalibrateAlgoKey = 10001, - SaveConfigKey = 10002, + CalibrateAlgoTimeKey = 10002, + SaveConfigKey = 10003, // xmrig cpu AVKey = 'v', diff --git a/src/core/ConfigLoader_platform.h b/src/core/ConfigLoader_platform.h index 05c4545a..9ec6a2a5 100644 --- a/src/core/ConfigLoader_platform.h +++ b/src/core/ConfigLoader_platform.h @@ -56,6 +56,7 @@ Options:\n\ #endif "\ --calibrate-algo run benchmarks before mining to measure hashrates of all supported algos\n\ + --calibrate-algo-time=N time in seconds to run each algo benchmark round (default: 60)\n\ -o, --url=URL URL of mining server\n\ -O, --userpass=U:P username:password pair for mining server\n\ -u, --user=USERNAME username for mining server\n\ @@ -114,6 +115,7 @@ static struct option const options[] = { { "donate-level", 1, nullptr, xmrig::IConfig::DonateLevelKey }, { "dry-run", 0, nullptr, xmrig::IConfig::DryRunKey }, { "calibrate-algo", 0, nullptr, xmrig::IConfig::CalibrateAlgoKey }, + { "calibrate-algo-time", 1, nullptr, xmrig::IConfig::CalibrateAlgoTimeKey }, { "save-config", 0, nullptr, xmrig::IConfig::SaveConfigKey }, { "help", 0, nullptr, xmrig::IConfig::HelpKey }, { "keepalive", 0, nullptr, xmrig::IConfig::KeepAliveKey }, diff --git a/src/workers/Benchmark.cpp b/src/workers/Benchmark.cpp index 1ba1d23b..add486d9 100644 --- a/src/workers/Benchmark.cpp +++ b/src/workers/Benchmark.cpp @@ -66,7 +66,7 @@ void Benchmark::onJobResult(const JobResult& result) { ++ m_hash_count; const uint64_t now = get_now(); if (!m_time_start) m_time_start = now; // time of measurements start (in ms) - else if (now - m_time_start > m_bench_secs*1000) { // end of becnhmark round for m_pa + else if (now - m_time_start > static_cast(m_controller->config()->calibrateAlgoTime())*1000) { // end of becnhmark round for m_pa const float hashrate = static_cast(m_hash_count) * result.diff / (now - m_time_start) * 1000.0f; m_controller->config()->set_algo_perf(m_pa, hashrate); // store hashrate result Log::i()->text(m_controller->config()->isColors() diff --git a/src/workers/Benchmark.h b/src/workers/Benchmark.h index f3262725..ae74310e 100644 --- a/src/workers/Benchmark.h +++ b/src/workers/Benchmark.h @@ -31,7 +31,6 @@ #include "core/Controller.h" class Benchmark : public IJobResultListener { - const uint64_t m_bench_secs = 5; // time in seconds to benchmark each perf algo xmrig::PerfAlgo m_pa; // current perf algo we benchmark uint64_t m_hash_count; // number of hashes calculated for current perf algo uint64_t m_time_start; // time of measurements start for current perf algo (in ms)