From 5f314edb2f738db01dbd84302a32fb5d929925da Mon Sep 17 00:00:00 2001 From: XMRig Date: Fri, 30 Oct 2020 23:24:01 +0700 Subject: [PATCH] Print benchmark url --- scripts/benchmark_10M.cmd | 3 +++ scripts/benchmark_1M.cmd | 3 +++ src/backend/common/Benchmark.cpp | 19 +++++++++++++++++-- src/backend/common/Benchmark.h | 1 + src/core/config/usage.h | 6 +++++- 5 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 scripts/benchmark_10M.cmd create mode 100644 scripts/benchmark_1M.cmd diff --git a/scripts/benchmark_10M.cmd b/scripts/benchmark_10M.cmd new file mode 100644 index 000000000..b67a82ecb --- /dev/null +++ b/scripts/benchmark_10M.cmd @@ -0,0 +1,3 @@ +@echo off +xmrig.exe --bench=10M --submit +pause diff --git a/scripts/benchmark_1M.cmd b/scripts/benchmark_1M.cmd new file mode 100644 index 000000000..0a0d95dbf --- /dev/null +++ b/scripts/benchmark_1M.cmd @@ -0,0 +1,3 @@ +@echo off +xmrig.exe --bench=1M --submit +pause diff --git a/src/backend/common/Benchmark.cpp b/src/backend/common/Benchmark.cpp index cd10ff553..dbb45c591 100644 --- a/src/backend/common/Benchmark.cpp +++ b/src/backend/common/Benchmark.cpp @@ -55,7 +55,9 @@ xmrig::Benchmark::Benchmark(const Job &job, size_t workers, const IBackend *back m_end(job.benchSize()), m_hash(job.benchHash()) { - m_httpListener = std::make_shared(this, Tags::bench()); + if (!m_token.isEmpty()) { + m_httpListener = std::make_shared(this, Tags::bench()); + } } @@ -73,7 +75,6 @@ bool xmrig::Benchmark::finish(uint64_t totalHashCount) const char *color = checkData ? ((m_data == checkData) ? GREEN_BOLD_S : RED_BOLD_S) : BLACK_BOLD_S; LOG_NOTICE("%s " WHITE_BOLD("benchmark finished in ") CYAN_BOLD("%.3f seconds") WHITE_BOLD_S " hash sum = " CLEAR "%s%016" PRIX64 CLEAR, Tags::bench(), dt, color, m_data); - LOG_INFO("%s " WHITE_BOLD("press ") MAGENTA_BOLD("Ctrl+C") WHITE_BOLD(" to exit"), Tags::bench()); if (!m_token.isEmpty()) { using namespace rapidjson; @@ -87,6 +88,9 @@ bool xmrig::Benchmark::finish(uint64_t totalHashCount) send(doc); } + else { + printExit(); + } return true; } @@ -152,6 +156,11 @@ void xmrig::Benchmark::onHttpData(const HttpData &data) if (data.status != 200) { return setError(data.statusName()); } + + if (m_doneTime) { + LOG_NOTICE("%s " WHITE_BOLD("benchmark submitted ") CYAN_BOLD("https://xmrig.com/benchmark/%s"), Tags::bench(), m_id.data()); + printExit(); + } } @@ -174,6 +183,12 @@ uint64_t xmrig::Benchmark::referenceHash() const } +void xmrig::Benchmark::printExit() +{ + LOG_INFO("%s " WHITE_BOLD("press ") MAGENTA_BOLD("Ctrl+C") WHITE_BOLD(" to exit"), Tags::bench()); +} + + void xmrig::Benchmark::send(const rapidjson::Value &body) { FetchRequest req(HTTP_PATCH, BenchConfig::kApiHost, BenchConfig::kApiPort, fmt::format("/1/benchmark/{}", m_id).c_str(), body, BenchConfig::kApiTLS, true); diff --git a/src/backend/common/Benchmark.h b/src/backend/common/Benchmark.h index 916203371..0e3881814 100644 --- a/src/backend/common/Benchmark.h +++ b/src/backend/common/Benchmark.h @@ -55,6 +55,7 @@ protected: private: uint64_t referenceHash() const; + void printExit(); void send(const rapidjson::Value &body); void setError(const char *message); diff --git a/src/core/config/usage.h b/src/core/config/usage.h index 49d22d0f5..58cb09370 100644 --- a/src/core/config/usage.h +++ b/src/core/config/usage.h @@ -181,7 +181,11 @@ static inline const std::string &usage() # ifdef XMRIG_FEATURE_BENCHMARK u += " --stress run continuous stress test to check system stability\n"; - u += " --bench=N run benchmark in offline mode, N can be between 1M and 10M\n"; + u += " --bench=N run benchmark, N can be between 1M and 10M\n"; + u += " --submit perform an online benchmark and submit result for sharing\n"; + u += " --verify=ID verify submitted benchmark by ID\n"; + u += " --seed=SEED custom RandomX seed for benchmark\n"; + u += " --hash=HASH compare benchmark result with specified hash\n"; # endif return u;