Add option "--print-time".
This commit is contained in:
parent
4e4c54314b
commit
fed163568e
5 changed files with 35 additions and 2 deletions
|
@ -72,6 +72,7 @@ Options:\n\
|
|||
--max-cpu-usage=N maximum CPU usage for automatic threads mode (default 75)\n\
|
||||
--safe safe adjust threads and av settings for current CPU\n\
|
||||
--nicehash enable nicehash support\n\
|
||||
--print-time=N print hashrate report every N seconds\n\
|
||||
-h, --help display this help and exit\n\
|
||||
-V, --version output version information and exit\n\
|
||||
";
|
||||
|
@ -94,6 +95,7 @@ static struct option const options[] = {
|
|||
{ "nicehash", 0, nullptr, 1006 },
|
||||
{ "no-color", 0, nullptr, 1002 },
|
||||
{ "pass", 1, nullptr, 'p' },
|
||||
{ "print-time", 1, nullptr, 1007 },
|
||||
{ "retries", 1, nullptr, 'r' },
|
||||
{ "retry-pause", 1, nullptr, 'R' },
|
||||
{ "safe", 0, nullptr, 1005 },
|
||||
|
@ -144,6 +146,7 @@ Options::Options(int argc, char **argv) :
|
|||
m_algoVariant(0),
|
||||
m_donateLevel(kDonateLevel),
|
||||
m_maxCpuUsage(75),
|
||||
m_printTime(60),
|
||||
m_retries(5),
|
||||
m_retryPause(5),
|
||||
m_threads(0),
|
||||
|
@ -360,6 +363,16 @@ bool Options::parseArg(int key, char *arg)
|
|||
m_nicehash = true;
|
||||
break;
|
||||
|
||||
case 1007: /* --print-time */
|
||||
v = strtol(arg, nullptr, 10);
|
||||
if (v < 0 || v > 1000) {
|
||||
showUsage(1);
|
||||
return false;
|
||||
}
|
||||
|
||||
m_printTime = v;
|
||||
break;
|
||||
|
||||
default:
|
||||
showUsage(1);
|
||||
return false;
|
||||
|
|
|
@ -64,6 +64,7 @@ public:
|
|||
inline int algo() const { return m_algo; }
|
||||
inline int algoVariant() const { return m_algoVariant; }
|
||||
inline int donateLevel() const { return m_donateLevel; }
|
||||
inline int printTime() const { return m_printTime; }
|
||||
inline int retries() const { return m_retries; }
|
||||
inline int retryPause() const { return m_retryPause; }
|
||||
inline int threads() const { return m_threads; }
|
||||
|
@ -103,6 +104,7 @@ private:
|
|||
int m_algoVariant;
|
||||
int m_donateLevel;
|
||||
int m_maxCpuUsage;
|
||||
int m_printTime;
|
||||
int m_retries;
|
||||
int m_retryPause;
|
||||
int m_threads;
|
||||
|
|
|
@ -58,6 +58,15 @@ Hashrate::Hashrate(int threads) :
|
|||
memset(m_counts[0], 0, sizeof(uint64_t) * kBucketSize);
|
||||
memset(m_timestamps[0], 0, sizeof(uint64_t) * kBucketSize);
|
||||
}
|
||||
|
||||
const int printTime = Options::i()->printTime();
|
||||
|
||||
if (printTime > 0) {
|
||||
uv_timer_init(uv_default_loop(), &m_timer);
|
||||
m_timer.data = this;
|
||||
|
||||
uv_timer_start(&m_timer, Hashrate::onReport, (printTime + 4) * 1000, printTime * 1000);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -159,3 +168,9 @@ void Hashrate::updateHighest()
|
|||
m_highest = highest;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Hashrate::onReport(uv_timer_t *handle)
|
||||
{
|
||||
static_cast<Hashrate*>(handle->data)->print();
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
|
||||
#include <stdint.h>
|
||||
#include <uv.h>
|
||||
|
||||
|
||||
class Hashrate
|
||||
|
@ -41,6 +42,8 @@ public:
|
|||
inline double highest() const { return m_highest; }
|
||||
|
||||
private:
|
||||
static void onReport(uv_timer_t *handle);
|
||||
|
||||
constexpr static size_t kBucketSize = 2 << 11;
|
||||
constexpr static size_t kBucketMask = kBucketSize - 1;
|
||||
|
||||
|
@ -49,6 +52,7 @@ private:
|
|||
uint32_t* m_top;
|
||||
uint64_t** m_counts;
|
||||
uint64_t** m_timestamps;
|
||||
uv_timer_t m_timer;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "Console.h"
|
||||
#include "interfaces/IJobResultListener.h"
|
||||
#include "Mem.h"
|
||||
#include "Options.h"
|
||||
#include "workers/DoubleWorker.h"
|
||||
#include "workers/Handle.h"
|
||||
#include "workers/Hashrate.h"
|
||||
|
@ -102,7 +103,6 @@ void Workers::submit(const JobResult &result)
|
|||
}
|
||||
|
||||
|
||||
|
||||
void Workers::onReady(void *arg)
|
||||
{
|
||||
auto handle = static_cast<Handle*>(arg);
|
||||
|
@ -148,6 +148,5 @@ void Workers::onTick(uv_timer_t *handle)
|
|||
|
||||
if ((m_ticks++ & 0xF) == 0) {
|
||||
m_hashrate->updateHighest();
|
||||
m_hashrate->print();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue