Added support for --user command line option for the benchmark.

This commit is contained in:
XMRig 2021-04-14 23:43:31 +07:00
parent 6bb29b3e7b
commit 748be760e8
No known key found for this signature in database
GPG key ID: 446A53638BE94409
4 changed files with 13 additions and 3 deletions

View file

@ -334,6 +334,7 @@ void xmrig::BenchClient::send(Request request)
{ {
doc.AddMember(StringRef(BenchConfig::kSize), m_benchmark->size(), allocator); doc.AddMember(StringRef(BenchConfig::kSize), m_benchmark->size(), allocator);
doc.AddMember(StringRef(BenchConfig::kAlgo), m_benchmark->algorithm().toJSON(), allocator); doc.AddMember(StringRef(BenchConfig::kAlgo), m_benchmark->algorithm().toJSON(), allocator);
doc.AddMember(StringRef(BenchConfig::kUser), m_benchmark->user().toJSON(), allocator);
doc.AddMember("version", APP_VERSION, allocator); doc.AddMember("version", APP_VERSION, allocator);
doc.AddMember("threads", m_threads, allocator); doc.AddMember("threads", m_threads, allocator);
doc.AddMember("steady_ready_ts", m_readyTime, allocator); doc.AddMember("steady_ready_ts", m_readyTime, allocator);

View file

@ -41,6 +41,7 @@ const char *BenchConfig::kSeed = "seed";
const char *BenchConfig::kSize = "size"; const char *BenchConfig::kSize = "size";
const char *BenchConfig::kSubmit = "submit"; const char *BenchConfig::kSubmit = "submit";
const char *BenchConfig::kToken = "token"; const char *BenchConfig::kToken = "token";
const char *BenchConfig::kUser = "user";
const char *BenchConfig::kVerify = "verify"; const char *BenchConfig::kVerify = "verify";
#ifndef XMRIG_DEBUG_BENCHMARK_API #ifndef XMRIG_DEBUG_BENCHMARK_API
@ -59,8 +60,8 @@ xmrig::BenchConfig::BenchConfig(uint32_t size, const String &id, const rapidjson
m_id(id), m_id(id),
m_seed(Json::getString(object, kSeed)), m_seed(Json::getString(object, kSeed)),
m_token(Json::getString(object, kToken)), m_token(Json::getString(object, kToken)),
m_size(size), m_user(Json::getString(object, kUser)),
m_hash(0) m_size(size)
{ {
if (!m_algorithm.isValid() || m_algorithm.family() != Algorithm::RANDOM_X) { if (!m_algorithm.isValid() || m_algorithm.family() != Algorithm::RANDOM_X) {
m_algorithm = Algorithm::RX_0; m_algorithm = Algorithm::RX_0;
@ -111,6 +112,7 @@ rapidjson::Value xmrig::BenchConfig::toJSON(rapidjson::Document &doc) const
out.AddMember(StringRef(kVerify), m_id.toJSON(), allocator); out.AddMember(StringRef(kVerify), m_id.toJSON(), allocator);
out.AddMember(StringRef(kToken), m_token.toJSON(), allocator); out.AddMember(StringRef(kToken), m_token.toJSON(), allocator);
out.AddMember(StringRef(kSeed), m_seed.toJSON(), allocator); out.AddMember(StringRef(kSeed), m_seed.toJSON(), allocator);
out.AddMember(StringRef(kUser), m_user.toJSON(), allocator);
if (m_hash) { if (m_hash) {
out.AddMember(StringRef(kHash), Value(fmt::format("{:016X}", m_hash).c_str(), allocator), allocator); out.AddMember(StringRef(kHash), Value(fmt::format("{:016X}", m_hash).c_str(), allocator), allocator);

View file

@ -39,6 +39,7 @@ public:
static const char *kSize; static const char *kSize;
static const char *kSubmit; static const char *kSubmit;
static const char *kToken; static const char *kToken;
static const char *kUser;
static const char *kVerify; static const char *kVerify;
# ifndef XMRIG_DEBUG_BENCHMARK_API # ifndef XMRIG_DEBUG_BENCHMARK_API
@ -59,6 +60,7 @@ public:
inline const String &id() const { return m_id; } inline const String &id() const { return m_id; }
inline const String &seed() const { return m_seed; } inline const String &seed() const { return m_seed; }
inline const String &token() const { return m_token; } inline const String &token() const { return m_token; }
inline const String &user() const { return m_user; }
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; }
@ -73,8 +75,9 @@ private:
String m_id; String m_id;
String m_seed; String m_seed;
String m_token; String m_token;
String m_user;
uint32_t m_size; uint32_t m_size;
uint64_t m_hash; uint64_t m_hash = 0;
}; };

View file

@ -262,6 +262,7 @@ void xmrig::ConfigTransform::transform(rapidjson::Document &doc, int key, const
case IConfig::BenchTokenKey: /* --token */ case IConfig::BenchTokenKey: /* --token */
case IConfig::BenchSeedKey: /* --seed */ case IConfig::BenchSeedKey: /* --seed */
case IConfig::BenchHashKey: /* --hash */ case IConfig::BenchHashKey: /* --hash */
case IConfig::UserKey: /* --user */
return transformBenchmark(doc, key, arg); return transformBenchmark(doc, key, arg);
# endif # endif
@ -347,6 +348,9 @@ void xmrig::ConfigTransform::transformBenchmark(rapidjson::Document &doc, int ke
case IConfig::BenchHashKey: /* --hash */ case IConfig::BenchHashKey: /* --hash */
return set(doc, BenchConfig::kBenchmark, BenchConfig::kHash, arg); return set(doc, BenchConfig::kBenchmark, BenchConfig::kHash, arg);
case IConfig::UserKey: /* --user */
return set(doc, BenchConfig::kBenchmark, BenchConfig::kUser, arg);
} }
} }
#endif #endif