Sync changes with amd miner and update summary.

This commit is contained in:
XMRig 2018-06-01 01:48:31 +07:00
parent 34a3454784
commit 009bd1a507
8 changed files with 97 additions and 74 deletions

View file

@ -35,7 +35,7 @@
#include "workers/Hashrate.h"
inline const char *format(double h, char* buf, size_t size)
inline static const char *format(double h, char *buf, size_t size)
{
if (isnormal(h)) {
snprintf(buf, size, "%03.1f", h);
@ -91,6 +91,9 @@ double Hashrate::calc(size_t ms) const
double Hashrate::calc(size_t threadId, size_t ms) const
{
assert(threadId < m_threads);
if (threadId >= m_threads) {
return nan("");
}
using namespace std::chrono;
const uint64_t now = time_point_cast<milliseconds>(high_resolution_clock::now()).time_since_epoch().count();
@ -149,14 +152,15 @@ void Hashrate::add(size_t threadId, uint64_t count, uint64_t timestamp)
}
void Hashrate::print()
void Hashrate::print() const
{
char num1[8] = { 0 };
char num2[8] = { 0 };
char num3[8] = { 0 };
char num4[8] = { 0 };
LOG_INFO(m_controller->config()->isColors() ? "\x1B[01;37mspeed\x1B[0m 2.5s/60s/15m \x1B[01;36m%s \x1B[22;36m%s %s \x1B[01;36mH/s\x1B[0m max: \x1B[01;36m%s H/s" : "speed 2.5s/60s/15m %s %s %s H/s max: %s H/s",
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")
: "speed 10s/60s/15m %s %s %s H/s max %s H/s",
format(calc(ShortInterval), num1, sizeof(num1)),
format(calc(MediumInterval), num2, sizeof(num2)),
format(calc(LargeInterval), num3, sizeof(num3)),
@ -180,6 +184,12 @@ void Hashrate::updateHighest()
}
const char *Hashrate::format(double h, char *buf, size_t size)
{
return ::format(h, buf, size);
}
void Hashrate::onReport(uv_timer_t *handle)
{
static_cast<Hashrate*>(handle->data)->print();

View file

@ -38,7 +38,7 @@ class Hashrate
{
public:
enum Intervals {
ShortInterval = 2500,
ShortInterval = 10000,
MediumInterval = 60000,
LargeInterval = 900000
};
@ -47,13 +47,15 @@ public:
double calc(size_t ms) const;
double calc(size_t threadId, size_t ms) const;
void add(size_t threadId, uint64_t count, uint64_t timestamp);
void print();
void print() const;
void stop();
void updateHighest();
inline double highest() const { return m_highest; }
inline size_t threads() const { return m_threads; }
static const char *format(double h, char *buf, size_t size);
private:
static void onReport(uv_timer_t *handle);