mirror of
https://github.com/jwinterm/xmr-stak.git
synced 2026-12-01 12:23:57 +01:00
Merge pull request #104 from psychocrypt/topic-hashrateReportCli
improve cli hash report
This commit is contained in:
@@ -49,6 +49,7 @@ namespace amd
|
||||
|
||||
minethd::minethd(miner_work& pWork, size_t iNo, GpuContext* ctx, const jconf::thd_cfg cfg)
|
||||
{
|
||||
this->backendType = iBackend::AMD;
|
||||
oWork = pWork;
|
||||
bQuit = 0;
|
||||
iThreadNo = (uint8_t)iNo;
|
||||
|
||||
@@ -94,6 +94,7 @@ bool minethd::thd_setaffinity(std::thread::native_handle_type h, uint64_t cpu_id
|
||||
|
||||
minethd::minethd(miner_work& pWork, size_t iNo, bool double_work, bool no_prefetch, int64_t affinity)
|
||||
{
|
||||
this->backendType = iBackend::CPU;
|
||||
oWork = pWork;
|
||||
bQuit = 0;
|
||||
iThreadNo = (uint8_t)iNo;
|
||||
|
||||
@@ -5,15 +5,31 @@
|
||||
#include <atomic>
|
||||
#include <cstdint>
|
||||
#include <climits>
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
namespace xmrstak
|
||||
{
|
||||
struct iBackend
|
||||
{
|
||||
|
||||
enum BackendType : uint32_t { UNKNOWN = 0, CPU = 1u, AMD = 2u, NVIDIA = 3u };
|
||||
|
||||
static std::string getName(const BackendType type)
|
||||
{
|
||||
std::vector<std::string> backendNames = {
|
||||
"UNKNOWN",
|
||||
"CPU",
|
||||
"AMD",
|
||||
"NVIDIA"
|
||||
};
|
||||
return backendNames[static_cast<uint32_t>(type)];
|
||||
}
|
||||
|
||||
std::atomic<uint64_t> iHashCount;
|
||||
std::atomic<uint64_t> iTimestamp;
|
||||
uint32_t iThreadNo;
|
||||
BackendType backendType = UNKNOWN;
|
||||
|
||||
iBackend() : iHashCount(0), iTimestamp(0)
|
||||
{
|
||||
|
||||
@@ -66,6 +66,7 @@ namespace nvidia
|
||||
|
||||
minethd::minethd(miner_work& pWork, size_t iNo, const jconf::thd_cfg& cfg)
|
||||
{
|
||||
this->backendType = iBackend::NVIDIA;
|
||||
oWork = pWork;
|
||||
bQuit = 0;
|
||||
iThreadNo = (uint8_t)iNo;
|
||||
|
||||
+51
-35
@@ -29,6 +29,7 @@
|
||||
#include "xmrstak/backend/miner_work.hpp"
|
||||
#include "xmrstak/backend/globalStates.hpp"
|
||||
#include "xmrstak/backend/backendConnector.hpp"
|
||||
#include "xmrstak/backend/iBackend.hpp"
|
||||
|
||||
#include "xmrstak/jconf.hpp"
|
||||
#include "xmrstak/misc/console.hpp"
|
||||
@@ -619,50 +620,65 @@ inline const char* hps_format(double h, char* buf, size_t l)
|
||||
void executor::hashrate_report(std::string& out)
|
||||
{
|
||||
char num[32];
|
||||
size_t nthd = pvThreads->size();
|
||||
|
||||
out.reserve(256 + nthd * 64);
|
||||
|
||||
double fTotal[3] = { 0.0, 0.0, 0.0};
|
||||
size_t i;
|
||||
|
||||
out.append("HASHRATE REPORT\n");
|
||||
out.append("| ID | 10s | 60s | 15m |");
|
||||
if(nthd != 1)
|
||||
out.append(" ID | 10s | 60s | 15m |\n");
|
||||
else
|
||||
out.append(1, '\n');
|
||||
|
||||
for (i = 0; i < nthd; i++)
|
||||
for( uint32_t b = 0; b < 4u; ++b)
|
||||
{
|
||||
double fHps[3];
|
||||
std::vector<xmrstak::iBackend*> backEnds;
|
||||
std::copy_if(pvThreads->begin(), pvThreads->end(), std::back_inserter(backEnds),
|
||||
[&](xmrstak::iBackend* backend)
|
||||
{
|
||||
return backend->backendType == b;
|
||||
}
|
||||
);
|
||||
|
||||
fHps[0] = telem->calc_telemetry_data(10000, i);
|
||||
fHps[1] = telem->calc_telemetry_data(60000, i);
|
||||
fHps[2] = telem->calc_telemetry_data(900000, i);
|
||||
size_t nthd = backEnds.size();
|
||||
if(nthd != 0)
|
||||
{
|
||||
out.reserve(256 + nthd * 64);
|
||||
|
||||
snprintf(num, sizeof(num), "| %2u |", (unsigned int)i);
|
||||
out.append(num);
|
||||
out.append(hps_format(fHps[0], num, sizeof(num))).append(" |");
|
||||
out.append(hps_format(fHps[1], num, sizeof(num))).append(" |");
|
||||
out.append(hps_format(fHps[2], num, sizeof(num))).append(1, ' ');
|
||||
size_t i;
|
||||
auto bType = static_cast<xmrstak::iBackend::BackendType>(b);
|
||||
out.append("HASHRATE REPORT - ").append(xmrstak::iBackend::getName(bType)).append("\n");
|
||||
out.append("| ID | 10s | 60s | 15m |");
|
||||
if(nthd != 1)
|
||||
out.append(" ID | 10s | 60s | 15m |\n");
|
||||
else
|
||||
out.append(1, '\n');
|
||||
|
||||
fTotal[0] += fHps[0];
|
||||
fTotal[1] += fHps[1];
|
||||
fTotal[2] += fHps[2];
|
||||
for (i = 0; i < nthd; i++)
|
||||
{
|
||||
double fHps[3];
|
||||
|
||||
if((i & 0x1) == 1) //Odd i's
|
||||
out.append("|\n");
|
||||
uint32_t tid = backEnds[i]->iThreadNo;
|
||||
fHps[0] = telem->calc_telemetry_data(10000, tid);
|
||||
fHps[1] = telem->calc_telemetry_data(60000, tid);
|
||||
fHps[2] = telem->calc_telemetry_data(900000, tid);
|
||||
|
||||
snprintf(num, sizeof(num), "| %2u |", (unsigned int)i);
|
||||
out.append(num);
|
||||
out.append(hps_format(fHps[0], num, sizeof(num))).append(" |");
|
||||
out.append(hps_format(fHps[1], num, sizeof(num))).append(" |");
|
||||
out.append(hps_format(fHps[2], num, sizeof(num))).append(1, ' ');
|
||||
|
||||
fTotal[0] += fHps[0];
|
||||
fTotal[1] += fHps[1];
|
||||
fTotal[2] += fHps[2];
|
||||
|
||||
if((i & 0x1) == 1) //Odd i's
|
||||
out.append("|\n");
|
||||
}
|
||||
|
||||
if((i & 0x1) == 1) //We had odd number of threads
|
||||
out.append("|\n");
|
||||
|
||||
if(nthd != 1)
|
||||
out.append("-----------------------------------------------------\n");
|
||||
else
|
||||
out.append("---------------------------\n");
|
||||
}
|
||||
}
|
||||
|
||||
if((i & 0x1) == 1) //We had odd number of threads
|
||||
out.append("|\n");
|
||||
|
||||
if(nthd != 1)
|
||||
out.append("-----------------------------------------------------\n");
|
||||
else
|
||||
out.append("---------------------------\n");
|
||||
|
||||
out.append("Totals: ");
|
||||
out.append(hps_format(fTotal[0], num, sizeof(num)));
|
||||
out.append(hps_format(fTotal[1], num, sizeof(num)));
|
||||
|
||||
Reference in New Issue
Block a user