3030#include " net/Network.h"
3131
3232#include < chrono>
33+ #include < cstring>
3334
3435namespace xmrig {
3536
36- MoBenchmark::MoBenchmark () : m_controller(nullptr ), m_isNewBenchRun(true ) {}
37+ MoBenchmark::MoBenchmark () : m_controller(nullptr ), m_isNewBenchRun(true ), m_isRawKawPow( false ) {}
3738
3839MoBenchmark::~MoBenchmark () {}
3940
@@ -69,35 +70,43 @@ rapidjson::Value MoBenchmark::toJSON(rapidjson::Document &doc) const
6970
7071 for (const Algorithm a : Algorithm::all ()) {
7172 if (algo_perf[a.id ()] == 0 .0f ) continue ;
72- obj.AddMember (StringRef (a. name ( )), algo_perf[a.id ()], allocator);
73+ obj.AddMember (StringRef (poolAlgoName (a )), algo_perf[a.id ()], allocator);
7374 }
7475
7576 return obj;
7677}
7778
7879void MoBenchmark::flush_perf () {
7980 for (const Algorithm::Id algo : Algorithm::all ()) algo_perf[algo] = 0 .0f ;
81+ m_isRawKawPow = false ;
8082}
8183
8284void MoBenchmark::read (const rapidjson::Value &value)
8385{
8486 flush_perf ();
8587 if (value.IsObject ()) {
8688 for (auto &member : value.GetObject ()) {
87- const Algorithm algo (member.name .GetString ());
89+ const bool rawKawPow = strcmp (member.name .GetString (), " kawpow1" ) == 0 ;
90+ const Algorithm algo (rawKawPow ? " kawpow" : member.name .GetString ());
8891 if (!algo.isValid ()) {
8992 LOG_INFO (" %s " BRIGHT_BLACK_BG (MAGENTA_BOLD_S " Ignoring wrong name for algo-perf[%s] " ), Tags::benchmark (), member.name .GetString ());
9093 continue ;
9194 }
92- if (member.value .IsDouble ()) {
93- algo_perf[algo.id ()] = member.value .GetDouble ();
95+ double perf = 0.0 ;
96+ if (member.value .IsDouble ()) perf = member.value .GetDouble ();
97+ else if (member.value .IsInt ()) perf = member.value .GetInt ();
98+ else {
99+ LOG_INFO (" %s " BRIGHT_BLACK_BG (MAGENTA_BOLD_S " Ignoring wrong value for algo-perf[%s] " ), Tags::benchmark (), member.name .GetString ());
94100 continue ;
95101 }
96- if (member.value .IsInt ()) {
97- algo_perf[algo.id ()] = member.value .GetInt ();
98- continue ;
102+ # ifdef XMRIG_ALGO_KAWPOW
103+ if (algo.id () == Algorithm::KAWPOW_RVN ) {
104+ if (!rawKawPow && m_isRawKawPow) continue ;
105+ m_isRawKawPow = rawKawPow;
99106 }
100- LOG_INFO (" %s " BRIGHT_BLACK_BG (MAGENTA_BOLD_S " Ignoring wrong value for algo-perf[%s] " ), Tags::benchmark (), member.name .GetString ());
107+ # endif
108+ algo_perf[algo.id ()] = perf;
109+ continue ;
101110 }
102111 }
103112 m_isNewBenchRun = false ;
@@ -108,6 +117,13 @@ void MoBenchmark::read(const rapidjson::Value &value)
108117 }
109118}
110119
120+ const char *MoBenchmark::poolAlgoName (const Algorithm &algo) const {
121+ # ifdef XMRIG_ALGO_KAWPOW
122+ if (algo.id () == Algorithm::KAWPOW_RVN && m_isRawKawPow) return " kawpow1" ;
123+ # endif
124+ return algo.name ();
125+ }
126+
111127double MoBenchmark::get_algo_perf (Algorithm::Id algo) const {
112128 switch (algo) {
113129 case Algorithm::CN_0 : return algo_perf[Algorithm::CN_CCX ] / 2 ;
@@ -140,6 +156,9 @@ void MoBenchmark::start() {
140156 run_next_bench_algo ();
141157 return ;
142158 }
159+ # ifdef XMRIG_ALGO_KAWPOW
160+ if (algo.id () == Algorithm::KAWPOW_RVN ) m_isRawKawPow = true ;
161+ # endif
143162 // calculate number of active miner backends in m_enabled_backend_count
144163 m_enabled_backend_count = 0 ;
145164 for (auto backend : m_controller->miner ()->backends ()) if (backend->isEnabled () && backend->isEnabled (algo)) ++ m_enabled_backend_count;
@@ -229,9 +248,6 @@ void MoBenchmark::onJobResult(const JobResult& result) {
229248 if (!(hashrate = t[1 ]))
230249 if (!(hashrate = t[0 ]))
231250 hashrate = static_cast <double >(m_hash_count) * result.diff / (now - m_bench_start) * 1000 .0f ;
232- # ifdef XMRIG_ALGO_KAWPOW
233- if (algo.id () == Algorithm::KAWPOW_RVN ) hashrate /= ((double )0xFFFFFFFFFFFFFFFF ) / 0xFF000000 ;
234- # endif
235251 algo_perf[algo.id ()] = hashrate; // store hashrate result
236252 LOG_INFO (" %s " BRIGHT_BLACK_BG (WHITE_BOLD_S " Algo " MAGENTA_BOLD_S " %s" WHITE_BOLD_S " hashrate: " CYAN_BOLD_S " %f " ), Tags::benchmark (), algo.name (), hashrate);
237253 run_next_bench_algo ();
0 commit comments