Remove benchmark size from Job class.

This commit is contained in:
XMRig 2020-11-17 05:28:42 +07:00
parent d8f9501ac8
commit e2ea11ffeb
No known key found for this signature in database
GPG key ID: 446A53638BE94409
9 changed files with 25 additions and 32 deletions

View file

@ -42,6 +42,7 @@ static uint64_t result = 0;
IBenchListener *BenchState::m_listener = nullptr;
uint32_t BenchState::m_size = 0;
} // namespace xmrig

View file

@ -41,10 +41,13 @@ public:
static void destroy();
static void done(uint64_t data, uint64_t ts);
inline static uint32_t size() { return m_size; }
inline static void setListener(IBenchListener *listener) { m_listener = listener; }
inline static void setSize(uint32_t size) { m_size = size; }
private:
static IBenchListener *m_listener;
static uint32_t m_size;
};

View file

@ -21,14 +21,15 @@
#include "backend/common/benchmark/BenchState.h"
#include "base/io/log/Log.h"
#include "base/io/log/Tags.h"
#include "base/net/stratum/Job.h"
#include "base/tools/Chrono.h"
xmrig::Benchmark::Benchmark(const Job &job, size_t workers, const IBackend *backend) :
#include <cinttypes>
xmrig::Benchmark::Benchmark(size_t workers, const IBackend *backend) :
m_backend(backend),
m_workers(workers),
m_end(job.benchSize())
m_workers(workers)
{
}
@ -54,7 +55,7 @@ void xmrig::Benchmark::printProgress() const
}
const double dt = static_cast<double>(Chrono::steadyMSecs() - m_startTime) / 1000.0;
const double percent = static_cast<double>(m_current) / m_end * 100.0;
const double percent = static_cast<double>(m_current) / BenchState::size() * 100.0;
LOG_NOTICE("%s " MAGENTA_BOLD("%5.2f%% ") CYAN_BOLD("%" PRIu64) CYAN("/%" PRIu64) BLACK_BOLD(" (%.3fs)"), Tags::bench(), percent, m_current, m_end, dt);
LOG_NOTICE("%s " MAGENTA_BOLD("%5.2f%% ") CYAN_BOLD("%" PRIu64) CYAN("/%" PRIu64) BLACK_BOLD(" (%.3fs)"), Tags::bench(), percent, m_current, BenchState::size(), dt);
}

View file

@ -27,7 +27,6 @@ namespace xmrig {
class IBackend;
class Job;
class Benchmark
@ -35,7 +34,7 @@ class Benchmark
public:
XMRIG_DISABLE_COPY_MOVE_DEFAULT(Benchmark)
Benchmark(const Job &job, size_t workers, const IBackend *backend);
Benchmark(size_t workers, const IBackend *backend);
~Benchmark() = default;
bool finish(uint64_t totalHashCount);
@ -45,7 +44,6 @@ public:
private:
const IBackend *m_backend;
const size_t m_workers;
const uint64_t m_end;
uint64_t m_current = 0;
uint64_t m_startTime = 0;
};