From 5d6a622b1813187ebdb96dc1338b88d602611a27 Mon Sep 17 00:00:00 2001 From: XMRig Date: Fri, 1 Jun 2018 02:33:21 +0700 Subject: [PATCH] New detailed hashrate report. --- src/workers/Workers.cpp | 31 +++++++++++++++++++++++++++++++ src/workers/Workers.h | 1 + 2 files changed, 32 insertions(+) diff --git a/src/workers/Workers.cpp b/src/workers/Workers.cpp index f6ec04b7d..0e75e7361 100644 --- a/src/workers/Workers.cpp +++ b/src/workers/Workers.cpp @@ -22,6 +22,7 @@ */ #include +#include #include @@ -55,6 +56,7 @@ uv_async_t Workers::m_async; uv_mutex_t Workers::m_mutex; uv_rwlock_t Workers::m_rwlock; uv_timer_t Workers::m_timer; +xmrig::Controller *Workers::m_controller = nullptr; Job Workers::job() @@ -89,6 +91,33 @@ size_t Workers::threads() void Workers::printHashrate(bool detail) { + assert(m_controller != nullptr); + if (!m_controller) { + return; + } + + if (detail) { + const bool isColors = m_controller->config()->isColors(); + char num1[8] = { 0 }; + char num2[8] = { 0 }; + char num3[8] = { 0 }; + + Log::i()->text("%s| THREAD | AFFINITY | 10s H/s | 60s H/s | 15m H/s |", isColors ? "\x1B[1;37m" : ""); + + size_t i = 0; + for (const xmrig::IThread *thread : m_controller->config()->threads()) { + Log::i()->text("| %6zu | %8" PRId64 " | %7s | %7s | %7s |", + thread->index(), + thread->affinity(), + Hashrate::format(m_hashrate->calc(thread->index(), Hashrate::ShortInterval), num1, sizeof num1), + Hashrate::format(m_hashrate->calc(thread->index(), Hashrate::MediumInterval), num2, sizeof num2), + Hashrate::format(m_hashrate->calc(thread->index(), Hashrate::LargeInterval), num3, sizeof num3) + ); + + i++; + } + } + m_hashrate->print(); } @@ -131,6 +160,8 @@ void Workers::setJob(const Job &job, bool donate) void Workers::start(xmrig::Controller *controller) { + m_controller = controller; + const std::vector &threads = controller->config()->threads(); m_status.algo = controller->config()->algorithm().algo(); m_status.colors = controller->config()->isColors(); diff --git a/src/workers/Workers.h b/src/workers/Workers.h index ca01e6985..1d619ceac 100644 --- a/src/workers/Workers.h +++ b/src/workers/Workers.h @@ -114,6 +114,7 @@ private: static uv_mutex_t m_mutex; static uv_rwlock_t m_rwlock; static uv_timer_t m_timer; + static xmrig::Controller *m_controller; };