mirror of
https://github.com/xmrig/xmrig.git
synced 2025-02-02 03:06:30 +00:00
Add support for benchmark in generated config.
This commit is contained in:
parent
3b6cfd9c4f
commit
e4283d5f53
5 changed files with 60 additions and 5 deletions
|
@ -194,6 +194,27 @@ void xmrig::Pools::print() const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void xmrig::Pools::toJSON(rapidjson::Value &out, rapidjson::Document &doc) const
|
||||||
|
{
|
||||||
|
using namespace rapidjson;
|
||||||
|
auto &allocator = doc.GetAllocator();
|
||||||
|
|
||||||
|
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||||
|
if (m_benchmark) {
|
||||||
|
out.AddMember(StringRef(BenchConfig::kBenchmark), m_benchmark->toJSON(doc), allocator);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
|
||||||
|
doc.AddMember(StringRef(kDonateLevel), m_donateLevel, allocator);
|
||||||
|
doc.AddMember(StringRef(kDonateOverProxy), m_proxyDonate, allocator);
|
||||||
|
out.AddMember(StringRef(kPools), toJSON(doc), allocator);
|
||||||
|
doc.AddMember(StringRef(kRetries), retries(), allocator);
|
||||||
|
doc.AddMember(StringRef(kRetryPause), retryPause(), allocator);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void xmrig::Pools::setDonateLevel(int level)
|
void xmrig::Pools::setDonateLevel(int level)
|
||||||
{
|
{
|
||||||
if (level >= kMinimumDonateLevel && level <= 99) {
|
if (level >= kMinimumDonateLevel && level <= 99) {
|
||||||
|
|
|
@ -73,6 +73,7 @@ public:
|
||||||
uint32_t benchSize() const;
|
uint32_t benchSize() const;
|
||||||
void load(const IJsonReader &reader);
|
void load(const IJsonReader &reader);
|
||||||
void print() const;
|
void print() const;
|
||||||
|
void toJSON(rapidjson::Value &out, rapidjson::Document &doc) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setDonateLevel(int level);
|
void setDonateLevel(int level);
|
||||||
|
|
|
@ -89,6 +89,39 @@ xmrig::BenchConfig *xmrig::BenchConfig::create(const rapidjson::Value &object)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
rapidjson::Value xmrig::BenchConfig::toJSON(rapidjson::Document &doc) const
|
||||||
|
{
|
||||||
|
using namespace rapidjson;
|
||||||
|
Value out(kObjectType);
|
||||||
|
auto &allocator = doc.GetAllocator();
|
||||||
|
|
||||||
|
if (m_size == 0) {
|
||||||
|
out.AddMember(StringRef(kSize), 0U, allocator);
|
||||||
|
}
|
||||||
|
else if (m_size < 1000000) {
|
||||||
|
out.AddMember(StringRef(kSize), Value(fmt::format("{}K", m_size / 1000).c_str(), allocator), allocator);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
out.AddMember(StringRef(kSize), Value(fmt::format("{}M", m_size / 1000000).c_str(), allocator), allocator);
|
||||||
|
}
|
||||||
|
|
||||||
|
out.AddMember(StringRef(kAlgo), m_algorithm.toJSON(), allocator);
|
||||||
|
out.AddMember(StringRef(kSubmit), m_submit, allocator);
|
||||||
|
out.AddMember(StringRef(kVerify), m_id.toJSON(), allocator);
|
||||||
|
out.AddMember(StringRef(kToken), m_token.toJSON(), allocator);
|
||||||
|
out.AddMember(StringRef(kSeed), m_seed.toJSON(), allocator);
|
||||||
|
|
||||||
|
if (m_hash) {
|
||||||
|
out.AddMember(StringRef(kHash), Value(fmt::format("{:016X}", m_hash).c_str(), allocator), allocator);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
out.AddMember(StringRef(kHash), kNullType, allocator);
|
||||||
|
}
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
uint32_t xmrig::BenchConfig::getSize(const char *benchmark)
|
uint32_t xmrig::BenchConfig::getSize(const char *benchmark)
|
||||||
{
|
{
|
||||||
if (!benchmark) {
|
if (!benchmark) {
|
||||||
|
|
|
@ -61,6 +61,8 @@ public:
|
||||||
inline uint32_t size() const { return m_size; }
|
inline uint32_t size() const { return m_size; }
|
||||||
inline uint64_t hash() const { return m_hash; }
|
inline uint64_t hash() const { return m_hash; }
|
||||||
|
|
||||||
|
rapidjson::Value toJSON(rapidjson::Document &doc) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static uint32_t getSize(const char *benchmark);
|
static uint32_t getSize(const char *benchmark);
|
||||||
|
|
||||||
|
|
|
@ -228,16 +228,14 @@ void xmrig::Config::getJSON(rapidjson::Document &doc) const
|
||||||
doc.AddMember(StringRef(kCuda), cuda().toJSON(doc), allocator);
|
doc.AddMember(StringRef(kCuda), cuda().toJSON(doc), allocator);
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
doc.AddMember(StringRef(Pools::kDonateLevel), m_pools.donateLevel(), allocator);
|
|
||||||
doc.AddMember(StringRef(Pools::kDonateOverProxy), m_pools.proxyDonate(), allocator);
|
|
||||||
doc.AddMember(StringRef(kLogFile), m_logFile.toJSON(), allocator);
|
doc.AddMember(StringRef(kLogFile), m_logFile.toJSON(), allocator);
|
||||||
doc.AddMember(StringRef(Pools::kPools), m_pools.toJSON(doc), allocator);
|
|
||||||
|
m_pools.toJSON(doc, doc);
|
||||||
|
|
||||||
doc.AddMember(StringRef(kPrintTime), printTime(), allocator);
|
doc.AddMember(StringRef(kPrintTime), printTime(), allocator);
|
||||||
# if defined(XMRIG_FEATURE_NVML) || defined (XMRIG_FEATURE_ADL)
|
# if defined(XMRIG_FEATURE_NVML) || defined (XMRIG_FEATURE_ADL)
|
||||||
doc.AddMember(StringRef(kHealthPrintTime), healthPrintTime(), allocator);
|
doc.AddMember(StringRef(kHealthPrintTime), healthPrintTime(), allocator);
|
||||||
# endif
|
# endif
|
||||||
doc.AddMember(StringRef(Pools::kRetries), m_pools.retries(), allocator);
|
|
||||||
doc.AddMember(StringRef(Pools::kRetryPause), m_pools.retryPause(), allocator);
|
|
||||||
doc.AddMember(StringRef(kSyslog), isSyslog(), allocator);
|
doc.AddMember(StringRef(kSyslog), isSyslog(), allocator);
|
||||||
|
|
||||||
# ifdef XMRIG_FEATURE_TLS
|
# ifdef XMRIG_FEATURE_TLS
|
||||||
|
|
Loading…
Reference in a new issue