mirror of
https://github.com/xmrig/xmrig.git
synced 2024-12-23 20:19:23 +00:00
Remove benchmark size from Job class.
This commit is contained in:
parent
d8f9501ac8
commit
e2ea11ffeb
9 changed files with 25 additions and 32 deletions
|
@ -42,6 +42,7 @@ static uint64_t result = 0;
|
||||||
|
|
||||||
|
|
||||||
IBenchListener *BenchState::m_listener = nullptr;
|
IBenchListener *BenchState::m_listener = nullptr;
|
||||||
|
uint32_t BenchState::m_size = 0;
|
||||||
|
|
||||||
|
|
||||||
} // namespace xmrig
|
} // namespace xmrig
|
||||||
|
|
|
@ -41,10 +41,13 @@ public:
|
||||||
static void destroy();
|
static void destroy();
|
||||||
static void done(uint64_t data, uint64_t ts);
|
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 setListener(IBenchListener *listener) { m_listener = listener; }
|
||||||
|
inline static void setSize(uint32_t size) { m_size = size; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static IBenchListener *m_listener;
|
static IBenchListener *m_listener;
|
||||||
|
static uint32_t m_size;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -21,14 +21,15 @@
|
||||||
#include "backend/common/benchmark/BenchState.h"
|
#include "backend/common/benchmark/BenchState.h"
|
||||||
#include "base/io/log/Log.h"
|
#include "base/io/log/Log.h"
|
||||||
#include "base/io/log/Tags.h"
|
#include "base/io/log/Tags.h"
|
||||||
#include "base/net/stratum/Job.h"
|
|
||||||
#include "base/tools/Chrono.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_backend(backend),
|
||||||
m_workers(workers),
|
m_workers(workers)
|
||||||
m_end(job.benchSize())
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +55,7 @@ void xmrig::Benchmark::printProgress() const
|
||||||
}
|
}
|
||||||
|
|
||||||
const double dt = static_cast<double>(Chrono::steadyMSecs() - m_startTime) / 1000.0;
|
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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,6 @@ namespace xmrig {
|
||||||
|
|
||||||
|
|
||||||
class IBackend;
|
class IBackend;
|
||||||
class Job;
|
|
||||||
|
|
||||||
|
|
||||||
class Benchmark
|
class Benchmark
|
||||||
|
@ -35,7 +34,7 @@ class Benchmark
|
||||||
public:
|
public:
|
||||||
XMRIG_DISABLE_COPY_MOVE_DEFAULT(Benchmark)
|
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;
|
~Benchmark() = default;
|
||||||
|
|
||||||
bool finish(uint64_t totalHashCount);
|
bool finish(uint64_t totalHashCount);
|
||||||
|
@ -45,7 +44,6 @@ public:
|
||||||
private:
|
private:
|
||||||
const IBackend *m_backend;
|
const IBackend *m_backend;
|
||||||
const size_t m_workers;
|
const size_t m_workers;
|
||||||
const uint64_t m_end;
|
|
||||||
uint64_t m_current = 0;
|
uint64_t m_current = 0;
|
||||||
uint64_t m_startTime = 0;
|
uint64_t m_startTime = 0;
|
||||||
};
|
};
|
||||||
|
|
|
@ -57,6 +57,7 @@
|
||||||
|
|
||||||
#ifdef XMRIG_FEATURE_BENCHMARK
|
#ifdef XMRIG_FEATURE_BENCHMARK
|
||||||
# include "backend/common/benchmark/Benchmark.h"
|
# include "backend/common/benchmark/Benchmark.h"
|
||||||
|
# include "backend/common/benchmark/BenchState.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -347,7 +348,7 @@ void xmrig::CpuBackend::setJob(const Job &job)
|
||||||
const auto &cpu = d_ptr->controller->config()->cpu();
|
const auto &cpu = d_ptr->controller->config()->cpu();
|
||||||
|
|
||||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||||
uint32_t benchSize = job.benchSize();
|
const uint32_t benchSize = BenchState::size();
|
||||||
# else
|
# else
|
||||||
constexpr uint32_t benchSize = 0;
|
constexpr uint32_t benchSize = 0;
|
||||||
# endif
|
# endif
|
||||||
|
@ -370,7 +371,7 @@ void xmrig::CpuBackend::setJob(const Job &job)
|
||||||
|
|
||||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||||
if (benchSize) {
|
if (benchSize) {
|
||||||
d_ptr->benchmark = std::make_shared<Benchmark>(job, threads.size(), this);
|
d_ptr->benchmark = std::make_shared<Benchmark>(threads.size(), this);
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
|
|
@ -174,10 +174,6 @@ void xmrig::Job::copy(const Job &other)
|
||||||
memcpy(m_rawBlob, other.m_rawBlob, sizeof(m_rawBlob));
|
memcpy(m_rawBlob, other.m_rawBlob, sizeof(m_rawBlob));
|
||||||
memcpy(m_rawTarget, other.m_rawTarget, sizeof(m_rawTarget));
|
memcpy(m_rawTarget, other.m_rawTarget, sizeof(m_rawTarget));
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
|
||||||
m_benchSize = other.m_benchSize;
|
|
||||||
# endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -209,8 +205,4 @@ void xmrig::Job::move(Job &&other)
|
||||||
memcpy(m_rawBlob, other.m_rawBlob, sizeof(m_rawBlob));
|
memcpy(m_rawBlob, other.m_rawBlob, sizeof(m_rawBlob));
|
||||||
memcpy(m_rawTarget, other.m_rawTarget, sizeof(m_rawTarget));
|
memcpy(m_rawTarget, other.m_rawTarget, sizeof(m_rawTarget));
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
|
||||||
m_benchSize = other.m_benchSize;
|
|
||||||
# endif
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,11 +111,6 @@ public:
|
||||||
inline Job &operator=(const Job &other) { copy(other); return *this; }
|
inline Job &operator=(const Job &other) { copy(other); return *this; }
|
||||||
inline Job &operator=(Job &&other) noexcept { move(std::move(other)); return *this; }
|
inline Job &operator=(Job &&other) noexcept { move(std::move(other)); return *this; }
|
||||||
|
|
||||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
|
||||||
inline uint32_t benchSize() const { return m_benchSize; }
|
|
||||||
inline void setBenchSize(uint32_t size) { m_benchSize = size; }
|
|
||||||
# endif
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void copy(const Job &other);
|
void copy(const Job &other);
|
||||||
void move(Job &&other);
|
void move(Job &&other);
|
||||||
|
@ -140,10 +135,6 @@ private:
|
||||||
char m_rawTarget[24]{};
|
char m_rawTarget[24]{};
|
||||||
String m_rawSeedHash;
|
String m_rawSeedHash;
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
|
||||||
uint32_t m_benchSize = 0;
|
|
||||||
# endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -46,9 +46,9 @@ xmrig::BenchClient::BenchClient(const std::shared_ptr<BenchConfig> &benchmark, I
|
||||||
m_job.setAlgorithm(m_benchmark->algorithm());
|
m_job.setAlgorithm(m_benchmark->algorithm());
|
||||||
m_job.setDiff(std::numeric_limits<uint64_t>::max());
|
m_job.setDiff(std::numeric_limits<uint64_t>::max());
|
||||||
m_job.setHeight(1);
|
m_job.setHeight(1);
|
||||||
m_job.setBenchSize(m_benchmark->size());
|
|
||||||
|
|
||||||
BenchState::setListener(this);
|
BenchState::setListener(this);
|
||||||
|
BenchState::setSize(m_benchmark->size());
|
||||||
|
|
||||||
# ifdef XMRIG_FEATURE_HTTP
|
# ifdef XMRIG_FEATURE_HTTP
|
||||||
if (m_benchmark->isSubmit()) {
|
if (m_benchmark->isSubmit()) {
|
||||||
|
@ -221,7 +221,7 @@ uint64_t xmrig::BenchClient::referenceHash() const
|
||||||
return m_hash;
|
return m_hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
return BenchState::referenceHash(m_job.algorithm(), m_job.benchSize(), m_threads);
|
return BenchState::referenceHash(m_job.algorithm(), BenchState::size(), m_threads);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -303,7 +303,8 @@ void xmrig::BenchClient::startVerify(const rapidjson::Value &value)
|
||||||
|
|
||||||
m_job.setAlgorithm(Json::getString(value, BenchConfig::kAlgo));
|
m_job.setAlgorithm(Json::getString(value, BenchConfig::kAlgo));
|
||||||
m_job.setSeedHash(Json::getString(value, BenchConfig::kSeed));
|
m_job.setSeedHash(Json::getString(value, BenchConfig::kSeed));
|
||||||
m_job.setBenchSize(Json::getUint(value, BenchConfig::kSize));
|
|
||||||
|
BenchState::setSize(Json::getUint(value, BenchConfig::kSize));
|
||||||
|
|
||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,6 +51,11 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef XMRIG_FEATURE_BENCHMARK
|
||||||
|
# include "backend/common/benchmark/BenchState.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cinttypes>
|
#include <cinttypes>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
@ -264,7 +269,7 @@ void xmrig::Network::setJob(IClient *client, const Job &job, bool donate)
|
||||||
const char *scale = NetworkState::scaleDiff(diff);
|
const char *scale = NetworkState::scaleDiff(diff);
|
||||||
|
|
||||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||||
const uint32_t size = job.benchSize();
|
const uint32_t size = BenchState::size();
|
||||||
if (size) {
|
if (size) {
|
||||||
LOG_NOTICE("%s " MAGENTA_BOLD("start benchmark ") "hashes " CYAN_BOLD("%u%s") " algo " WHITE_BOLD("%s") " print_time " CYAN_BOLD("%us"),
|
LOG_NOTICE("%s " MAGENTA_BOLD("start benchmark ") "hashes " CYAN_BOLD("%u%s") " algo " WHITE_BOLD("%s") " print_time " CYAN_BOLD("%us"),
|
||||||
Tags::bench(),
|
Tags::bench(),
|
||||||
|
|
Loading…
Reference in a new issue