diff --git a/doc/BENCHMARK.md b/doc/BENCHMARK.md index a05294b40..63b679262 100644 --- a/doc/BENCHMARK.md +++ b/doc/BENCHMARK.md @@ -7,7 +7,7 @@ xmrig --bench=10M xmrig --bench=1M -a rx/wow xmrig --bench=10M -a rx/wow ``` -This will run 1 or 10 millions RandomX hashes and print the time it took. First two commands use Monero variant (2 MB per thread, best for Zen2/Zen3 CPUs), second two commands use Wownero variant (1 MB per thread, useful for Intel and 1st gen Zen/Zen+ CPUs). +This will run between 1 and 10 million RandomX hashes, depending on `bench` parameter, and print the time it took. First two commands use Monero variant (2 MB per thread, best for Zen2/Zen3 CPUs), second two commands use Wownero variant (1 MB per thread, useful for Intel and 1st gen Zen/Zen+ CPUs). Checksum of all the hashes will be also printed to check stability of your hardware: if it's green then it's correct, if it's red then there was hardware error during computation. No Internet connection is required for the benchmark. diff --git a/src/backend/common/Workers.cpp b/src/backend/common/Workers.cpp index ae09f15bb..8dd2b1456 100644 --- a/src/backend/common/Workers.cpp +++ b/src/backend/common/Workers.cpp @@ -30,6 +30,7 @@ #include "backend/cpu/CpuWorker.h" #include "base/io/log/Log.h" #include "base/io/log/Tags.h" +#include "base/net/stratum/Pool.h" #include "base/tools/Chrono.h" #include "base/tools/Object.h" #include "core/Miner.h" @@ -205,32 +206,31 @@ bool xmrig::Workers::tick(uint64_t) d_ptr->hashrate->add(0, totalHashCount, Chrono::steadyMSecs()); } - if (d_ptr->bench && (benchDone == m_workers.size())) { - const double dt = (benchDoneTime - d_ptr->startTime) / 1000.0; + if (d_ptr->bench) { + Pool::benchProgress = std::min(static_cast((totalHashCount * 100U) / d_ptr->bench), 100U); - static uint64_t hashCheck[Algorithm::MAX][2] = {}; - hashCheck[Algorithm::RX_0][0] = 0x898B6E0431C28A6BULL; - hashCheck[Algorithm::RX_0][1] = 0xB5231262E2792B26ULL; - hashCheck[Algorithm::RX_WOW][0] = 0x0F3E5400B39EA96AULL; - hashCheck[Algorithm::RX_WOW][1] = 0x0F9E00C5A511C200ULL; + if (benchDone == m_workers.size()) { + const double dt = (benchDoneTime - d_ptr->startTime) / 1000.0; - int k = -1; + uint64_t checkData = 0; - switch (d_ptr->bench) { - case 1000000: - k = 0; - break; + const Algorithm::Id algo = d_ptr->benchAlgo.id(); + const uint32_t N = (d_ptr->bench / 1000000) - 1; - case 10000000: - k = 1; - break; + if (((algo == Algorithm::RX_0) || (algo == Algorithm::RX_WOW)) && ((d_ptr->bench % 1000000) == 0) && (N < 10)) { + static uint64_t hashCheck[2][10] = { + { 0x898B6E0431C28A6BULL, 0xEE9468F8B40926BCULL, 0xC2BC5D11724813C0ULL, 0x3A2C7B285B87F941ULL, 0x3B5BD2C3A16B450EULL, 0x5CD0602F20C5C7C4ULL, 0x101DE939474B6812ULL, 0x52B765A1B156C6ECULL, 0x323935102AB6B45CULL, 0xB5231262E2792B26ULL }, + { 0x0F3E5400B39EA96AULL, 0x85944CCFA2752D1FULL, 0x64AFFCAE991811BAULL, 0x3E4D0B836D3B13BAULL, 0xEB7417D621271166ULL, 0x97FFE10C0949FFA5ULL, 0x84CAC0F8879A4BA1ULL, 0xA1B79F031DA2459FULL, 0x9B65226DA873E65DULL, 0x0F9E00C5A511C200ULL }, + }; + + checkData = hashCheck[(algo == Algorithm::RX_0) ? 0 : 1][N]; + } + + const char* color = checkData ? ((benchData == checkData) ? GREEN_BOLD_S : RED_BOLD_S) : BLACK_BOLD_S; + + LOG_INFO("%s Benchmark finished in %.3f seconds, hash sum = %s%016" PRIX64 CLEAR, Tags::miner(), dt, color, benchData); + return false; } - - const uint64_t checkData = (k >= 0) ? hashCheck[d_ptr->benchAlgo.id()][k] : 0; - const char* color = checkData ? ((benchData == checkData) ? GREEN_BOLD_S : RED_BOLD_S) : BLACK_BOLD_S; - - LOG_INFO("%s Benchmark finished in %.3f seconds, hash sum = %s%016" PRIX64 CLEAR, Tags::miner(), dt, color, benchData); - return false; } return true; diff --git a/src/base/net/stratum/Pool.cpp b/src/base/net/stratum/Pool.cpp index b09559c2a..bacc2182e 100644 --- a/src/base/net/stratum/Pool.cpp +++ b/src/base/net/stratum/Pool.cpp @@ -86,6 +86,9 @@ const char *Pool::kBenchmark = "benchmark"; const char *Pool::kNicehashHost = "nicehash.com"; +uint32_t Pool::benchProgress = 0; + + } @@ -136,11 +139,13 @@ xmrig::Pool::Pool(const rapidjson::Value &object) : const char* benchSize = Json::getString(object, kBenchmark, nullptr); if (benchSize) { - if (strcasecmp(benchSize, "1M") == 0) { - m_benchSize = 1000000; - } - else if (strcasecmp(benchSize, "10M") == 0) { - m_benchSize = 10000000; + std::string s; + for (int i = 1; i <= 10; ++i) { + s = std::to_string(i) + "M"; + if (strcasecmp(benchSize, s.c_str()) == 0) { + m_benchSize = i * 1000000; + break; + } } } diff --git a/src/base/net/stratum/Pool.h b/src/base/net/stratum/Pool.h index dd4158a93..bb1aaf615 100644 --- a/src/base/net/stratum/Pool.h +++ b/src/base/net/stratum/Pool.h @@ -121,6 +121,8 @@ public: void print() const; # endif + static uint32_t benchProgress; + private: enum Flags { FLAG_ENABLED, diff --git a/src/core/Miner.cpp b/src/core/Miner.cpp index b3032cf14..8711c1cb3 100644 --- a/src/core/Miner.cpp +++ b/src/core/Miner.cpp @@ -304,8 +304,13 @@ public: } # endif - LOG_INFO("%s " WHITE_BOLD("speed") " 10s/60s/15m " CYAN_BOLD("%s") CYAN(" %s %s ") CYAN_BOLD("%s") " max " CYAN_BOLD("%s %s"), - Tags::miner(), + char benchProgress[8] = {}; + if (Pool::benchProgress) { + sprintf(benchProgress, "%3u%% ", Pool::benchProgress); + } + + LOG_INFO("%s %s" WHITE_BOLD("speed") " 10s/60s/15m " CYAN_BOLD("%s") CYAN(" %s %s ") CYAN_BOLD("%s") " max " CYAN_BOLD("%s %s"), + Tags::miner(), benchProgress, Hashrate::format(speed[0] * scale, num, sizeof(num) / 4), Hashrate::format(speed[1] * scale, num + 16, sizeof(num) / 4), Hashrate::format(speed[2] * scale, num + 16 * 2, sizeof(num) / 4), h, diff --git a/src/core/config/usage.h b/src/core/config/usage.h index 15393f9c9..c6fc4cf34 100644 --- a/src/core/config/usage.h +++ b/src/core/config/usage.h @@ -179,7 +179,7 @@ static inline const std::string &usage() # endif u += " --pause-on-battery pause mine on battery power\n"; u += " --stress run continuous stress test to check system stability\n"; - u += " --bench=N run benchmark in offline mode, N can be 1M or 10M\n"; + u += " --bench=N run benchmark in offline mode, N can be between 1M and 10M\n"; return u; }