mirror of
https://github.com/xmrig/xmrig.git
synced 2024-11-17 00:07:44 +00:00
New hashtable report.
This commit is contained in:
parent
e759ddca49
commit
4e4c54314b
4 changed files with 57 additions and 7 deletions
|
@ -107,7 +107,13 @@ void Network::onJobReceived(Client *client, const Job &job)
|
||||||
|
|
||||||
void Network::onJobResult(const JobResult &result)
|
void Network::onJobResult(const JobResult &result)
|
||||||
{
|
{
|
||||||
|
if (m_options->colors()) {
|
||||||
|
LOG_NOTICE("\x1B[01;32mSHARE FOUND");
|
||||||
|
}
|
||||||
|
else {
|
||||||
LOG_NOTICE("SHARE FOUND");
|
LOG_NOTICE("SHARE FOUND");
|
||||||
|
}
|
||||||
|
|
||||||
m_pools[result.poolId]->submit(result);
|
m_pools[result.poolId]->submit(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,7 +163,7 @@ void Network::addPool(const Url *url)
|
||||||
void Network::setJob(Client *client, const Job &job)
|
void Network::setJob(Client *client, const Job &job)
|
||||||
{
|
{
|
||||||
if (m_options->colors()) {
|
if (m_options->colors()) {
|
||||||
LOG_INFO("\x1B[01;33mnew job\x1B[0m from \"%s:%d\", diff: %d", client->host(), client->port(), job.diff());
|
LOG_INFO("\x1B[01;35mnew job\x1B[0m from \"%s:%d\", diff: %d", client->host(), client->port(), job.diff());
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -22,15 +22,28 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <memory.h>
|
|
||||||
#include <cmath>
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
#include <cmath>
|
||||||
|
#include <memory.h>
|
||||||
|
|
||||||
#include "Console.h"
|
#include "Console.h"
|
||||||
|
#include "Options.h"
|
||||||
#include "workers/Hashrate.h"
|
#include "workers/Hashrate.h"
|
||||||
|
|
||||||
|
|
||||||
|
inline const char *format(double h, char* buf, size_t size)
|
||||||
|
{
|
||||||
|
if (std::isnormal(h)) {
|
||||||
|
snprintf(buf, size, "%03.1f", h);
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
return "n/a";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Hashrate::Hashrate(int threads) :
|
Hashrate::Hashrate(int threads) :
|
||||||
|
m_highest(0.0),
|
||||||
m_threads(threads)
|
m_threads(threads)
|
||||||
{
|
{
|
||||||
m_counts = new uint64_t*[threads];
|
m_counts = new uint64_t*[threads];
|
||||||
|
@ -50,7 +63,7 @@ Hashrate::Hashrate(int threads) :
|
||||||
|
|
||||||
double Hashrate::calc(size_t ms) const
|
double Hashrate::calc(size_t ms) const
|
||||||
{
|
{
|
||||||
double result = .0;
|
double result = 0.0;
|
||||||
double data;
|
double data;
|
||||||
|
|
||||||
for (int i = 0; i < m_threads; ++i) {
|
for (int i = 0; i < m_threads; ++i) {
|
||||||
|
@ -121,3 +134,28 @@ void Hashrate::add(size_t threadId, uint64_t count, uint64_t timestamp)
|
||||||
|
|
||||||
m_top[threadId] = (top + 1) & kBucketMask;
|
m_top[threadId] = (top + 1) & kBucketMask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Hashrate::print()
|
||||||
|
{
|
||||||
|
char num1[8];
|
||||||
|
char num2[8];
|
||||||
|
char num3[8];
|
||||||
|
char num4[8];
|
||||||
|
|
||||||
|
LOG_INFO(Options::i()->colors() ? "\x1B[01;37mspeed\x1B[0m 2.5s/60s/15m \x1B[01;36m%s \x1B[22;36m%s %s \x1B[01;36mH/s\x1B[0m highest: \x1B[01;36m%s H/s" : "speed 2.5s/60s/15m %s %s %s H/s highest: %s H/s",
|
||||||
|
format(calc(2500), num1, sizeof(num1)),
|
||||||
|
format(calc(60000), num2, sizeof(num2)),
|
||||||
|
format(calc(900000), num3, sizeof(num3)),
|
||||||
|
format(m_highest, num4, sizeof(num4))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Hashrate::updateHighest()
|
||||||
|
{
|
||||||
|
double highest = calc(2500);
|
||||||
|
if (std::isnormal(highest) && highest > m_highest) {
|
||||||
|
m_highest = highest;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -35,11 +35,16 @@ public:
|
||||||
double calc(size_t ms) const;
|
double calc(size_t ms) const;
|
||||||
double calc(size_t threadId, 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 add(size_t threadId, uint64_t count, uint64_t timestamp);
|
||||||
|
void print();
|
||||||
|
void updateHighest();
|
||||||
|
|
||||||
|
inline double highest() const { return m_highest; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
constexpr static size_t kBucketSize = 2 << 11;
|
constexpr static size_t kBucketSize = 2 << 11;
|
||||||
constexpr static size_t kBucketMask = kBucketSize - 1;
|
constexpr static size_t kBucketMask = kBucketSize - 1;
|
||||||
|
|
||||||
|
double m_highest;
|
||||||
int m_threads;
|
int m_threads;
|
||||||
uint32_t* m_top;
|
uint32_t* m_top;
|
||||||
uint64_t** m_counts;
|
uint64_t** m_counts;
|
||||||
|
|
|
@ -147,6 +147,7 @@ void Workers::onTick(uv_timer_t *handle)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((m_ticks++ & 0xF) == 0) {
|
if ((m_ticks++ & 0xF) == 0) {
|
||||||
LOG_NOTICE("%03.1f H/s", m_hashrate->calc(2500));
|
m_hashrate->updateHighest();
|
||||||
|
m_hashrate->print();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue