Added a new log line 'totals'
This commit is contained in:
parent
2959e01784
commit
97f2782b26
2 changed files with 55 additions and 10 deletions
|
@ -62,7 +62,8 @@ inline static const char *format(double h, char *buf, size_t size)
|
||||||
Hashrate::Hashrate(size_t threads, xmrig::Controller *controller) :
|
Hashrate::Hashrate(size_t threads, xmrig::Controller *controller) :
|
||||||
m_highest(0.0),
|
m_highest(0.0),
|
||||||
m_threads(threads),
|
m_threads(threads),
|
||||||
m_controller(controller)
|
m_controller(controller),
|
||||||
|
m_start_time(time(NULL))
|
||||||
{
|
{
|
||||||
m_counts = new uint64_t*[threads];
|
m_counts = new uint64_t*[threads];
|
||||||
m_timestamps = new uint64_t*[threads];
|
m_timestamps = new uint64_t*[threads];
|
||||||
|
@ -174,6 +175,11 @@ uint64_t Hashrate::count(size_t threadId) const
|
||||||
return m_totals[threadId];
|
return m_totals[threadId];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint64_t Hashrate::elapsed() const
|
||||||
|
{
|
||||||
|
return time(NULL) - m_start_time;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Hashrate::add(size_t threadId, uint64_t count, uint64_t timestamp)
|
void Hashrate::add(size_t threadId, uint64_t count, uint64_t timestamp)
|
||||||
{
|
{
|
||||||
|
@ -193,16 +199,25 @@ void Hashrate::print() const
|
||||||
char num2[8] = { 0 };
|
char num2[8] = { 0 };
|
||||||
char num3[8] = { 0 };
|
char num3[8] = { 0 };
|
||||||
char num4[8] = { 0 };
|
char num4[8] = { 0 };
|
||||||
char num5[64] = { 0 };
|
char num5[128] = { 0 };
|
||||||
|
char num6[128] = { 0 };
|
||||||
|
char num7[128] = { 0 };
|
||||||
|
|
||||||
LOG_INFO(m_controller->config()->isColors() ? WHITE_BOLD("speed") " 10s/60s/15m " CYAN_BOLD("%s") CYAN(" %s %s ") CYAN_BOLD("H/s") " max " CYAN_BOLD("%s H/s") " total " CYAN_BOLD("%s")
|
bool color = m_controller->config()->isColors();
|
||||||
: "speed 10s/60s/15m %s %s %s H/s max %s H/s total %d",
|
uint64_t e = elapsed();
|
||||||
|
uint64_t c = count();
|
||||||
|
|
||||||
|
LOG_INFO(color ? WHITE_BOLD("speed") " 10s/60s/15m " CYAN_BOLD("%s") CYAN(" %s %s ") CYAN_BOLD("H/s") " max " CYAN_BOLD("%s H/s") : "speed 10s/60s/15m %s %s %s H/s max %s H/s",
|
||||||
format(calc(ShortInterval), num1, sizeof(num1)),
|
format(calc(ShortInterval), num1, sizeof(num1)),
|
||||||
format(calc(MediumInterval), num2, sizeof(num2)),
|
format(calc(MediumInterval), num2, sizeof(num2)),
|
||||||
format(calc(LargeInterval), num3, sizeof(num3)),
|
format(calc(LargeInterval), num3, sizeof(num3)),
|
||||||
format(m_highest, num4, sizeof(num4)),
|
format(m_highest, num4, sizeof(num4))
|
||||||
siFormat(count(), num5, sizeof(num5))
|
|
||||||
);
|
);
|
||||||
|
LOG_INFO(color ? WHITE_BOLD("totals") " time %s hashes %s rate " CYAN("%s ") CYAN_BOLD("H/s") : "totals: time %s hashes %s rate %s H/s",
|
||||||
|
timeFormat(e, num5, sizeof(num5), color),
|
||||||
|
siFormat(c, num6, sizeof(num6), color),
|
||||||
|
format(c * 1.0 / e, num7, sizeof(num7))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -226,7 +241,7 @@ const char *Hashrate::format(double h, char *buf, size_t size)
|
||||||
return ::format(h, buf, size);
|
return ::format(h, buf, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *Hashrate::siFormat(uint64_t h, char *buf, size_t size)
|
const char *Hashrate::siFormat(uint64_t h, char *buf, size_t size, bool color)
|
||||||
{
|
{
|
||||||
|
|
||||||
char c[2];
|
char c[2];
|
||||||
|
@ -249,12 +264,39 @@ const char *Hashrate::siFormat(uint64_t h, char *buf, size_t size)
|
||||||
h /= pow10(3);
|
h /= pow10(3);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
snprintf(buf, size, "%lu", h);
|
snprintf(buf, size, (color) ? CYAN("%lu") : "%lu", h);
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snprintf(buf, size, (color) ? CYAN("%lu.%03lu") CYAN_BOLD("%s") : "%lu.%03lu%s", h, d, c);
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
snprintf(buf, size, "%lu.%lu%s", h, d, c);
|
const char *Hashrate::timeFormat(uint64_t s, char *buf, size_t size, bool color)
|
||||||
|
{
|
||||||
|
uint64_t d = 0;
|
||||||
|
uint64_t h = 0;
|
||||||
|
uint64_t m = 0;
|
||||||
|
|
||||||
|
if (s > 3600 * 24) {
|
||||||
|
d = s / (3600*24);
|
||||||
|
s = s % (3600*24);
|
||||||
|
}
|
||||||
|
if (s > 3600) {
|
||||||
|
h = s / (3600);
|
||||||
|
s = s % (3600);
|
||||||
|
}
|
||||||
|
if (s > 60) {
|
||||||
|
m = s / (60);
|
||||||
|
s = s % (60);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!color) {
|
||||||
|
snprintf(buf, size, "%02lud::%02luh::%02lum::%02lus", d, h, m, s);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
snprintf(buf, size, CYAN("%02lu") CYAN_BOLD("d") CYAN("%02lu") CYAN_BOLD("h") CYAN("%02lu") CYAN_BOLD("m") CYAN("%02lu") CYAN_BOLD("s"), d, h, m, s);
|
||||||
|
}
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,7 @@ public:
|
||||||
double calc(size_t threadId, size_t ms) const;
|
double calc(size_t threadId, size_t ms) const;
|
||||||
uint64_t count() const;
|
uint64_t count() const;
|
||||||
uint64_t count(size_t threadId) const;
|
uint64_t count(size_t threadId) const;
|
||||||
|
uint64_t elapsed() const;
|
||||||
void add(size_t threadId, uint64_t count, uint64_t timestamp);
|
void add(size_t threadId, uint64_t count, uint64_t timestamp);
|
||||||
void print() const;
|
void print() const;
|
||||||
void stop();
|
void stop();
|
||||||
|
@ -57,7 +58,8 @@ public:
|
||||||
inline size_t threads() const { return m_threads; }
|
inline size_t threads() const { return m_threads; }
|
||||||
|
|
||||||
static const char *format(double h, char *buf, size_t size);
|
static const char *format(double h, char *buf, size_t size);
|
||||||
static const char *siFormat(uint64_t h, char *buf, size_t size);
|
static const char *siFormat(uint64_t h, char *buf, size_t size, bool color=false);
|
||||||
|
static const char *timeFormat(uint64_t t, char *buf, size_t size, bool color=false);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void onReport(uv_timer_t *handle);
|
static void onReport(uv_timer_t *handle);
|
||||||
|
@ -73,6 +75,7 @@ private:
|
||||||
uint64_t** m_timestamps;
|
uint64_t** m_timestamps;
|
||||||
uv_timer_t m_timer;
|
uv_timer_t m_timer;
|
||||||
xmrig::Controller *m_controller;
|
xmrig::Controller *m_controller;
|
||||||
|
time_t m_start_time;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue