Metrics screen: display hash rates using SI prefixes rather than as powers of 2.
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
This commit is contained in:
parent
976dce7696
commit
460a601e9b
|
@ -256,6 +256,24 @@ std::string DisplaySize(size_t value)
|
||||||
return strprintf(_("%.2f TiB"), value / coef);
|
return strprintf(_("%.2f TiB"), value / coef);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string DisplayHashRate(double value)
|
||||||
|
{
|
||||||
|
double coef = 1.0;
|
||||||
|
if (value < 1000.0 * coef)
|
||||||
|
return strprintf(_("%.3f Sol/s"), value);
|
||||||
|
coef *= 1000.0;
|
||||||
|
if (value < 1000.0 * coef)
|
||||||
|
return strprintf(_("%.3f kSol/s"), value / coef);
|
||||||
|
coef *= 1000.0;
|
||||||
|
if (value < 1000.0 * coef)
|
||||||
|
return strprintf(_("%.3f MSol/s"), value / coef);
|
||||||
|
coef *= 1000.0;
|
||||||
|
if (value < 1000.0 * coef)
|
||||||
|
return strprintf(_("%.3f GSol/s"), value / coef);
|
||||||
|
coef *= 1000.0;
|
||||||
|
return strprintf(_("%.3f TSol/s"), value / coef);
|
||||||
|
}
|
||||||
|
|
||||||
boost::optional<int64_t> SecondsLeftToNextEpoch(const Consensus::Params& params, int currentHeight)
|
boost::optional<int64_t> SecondsLeftToNextEpoch(const Consensus::Params& params, int currentHeight)
|
||||||
{
|
{
|
||||||
auto nextHeight = NextActivationHeight(currentHeight, params);
|
auto nextHeight = NextActivationHeight(currentHeight, params);
|
||||||
|
@ -276,7 +294,6 @@ int printStats(bool isScreen, bool mining)
|
||||||
int64_t currentHeadersTime;
|
int64_t currentHeadersTime;
|
||||||
size_t connections;
|
size_t connections;
|
||||||
int64_t netsolps;
|
int64_t netsolps;
|
||||||
double netsolpsLog = 1.0;
|
|
||||||
const Consensus::Params& params = Params().GetConsensus();
|
const Consensus::Params& params = Params().GetConsensus();
|
||||||
{
|
{
|
||||||
LOCK2(cs_main, cs_vNodes);
|
LOCK2(cs_main, cs_vNodes);
|
||||||
|
@ -285,12 +302,8 @@ int printStats(bool isScreen, bool mining)
|
||||||
currentHeadersTime = pindexBestHeader ? pindexBestHeader->nTime : 0;
|
currentHeadersTime = pindexBestHeader ? pindexBestHeader->nTime : 0;
|
||||||
connections = vNodes.size();
|
connections = vNodes.size();
|
||||||
netsolps = GetNetworkHashPS(120, -1);
|
netsolps = GetNetworkHashPS(120, -1);
|
||||||
netsolpsLog = std::log2(netsolps);
|
|
||||||
}
|
}
|
||||||
auto localsolps = GetLocalSolPS();
|
auto localsolps = GetLocalSolPS();
|
||||||
double localsolpsLog = 0.0;
|
|
||||||
if (localsolps > 0)
|
|
||||||
localsolpsLog = std::log2(localsolps);
|
|
||||||
|
|
||||||
if (IsInitialBlockDownload(Params())) {
|
if (IsInitialBlockDownload(Params())) {
|
||||||
if (fReindex) {
|
if (fReindex) {
|
||||||
|
@ -347,9 +360,9 @@ int printStats(bool isScreen, bool mining)
|
||||||
}
|
}
|
||||||
std::cout << " " << _("Next upgrade") << " | " << strUpgradeTime << std::endl;
|
std::cout << " " << _("Next upgrade") << " | " << strUpgradeTime << std::endl;
|
||||||
std::cout << " " << _("Connections") << " | " << connections << std::endl;
|
std::cout << " " << _("Connections") << " | " << connections << std::endl;
|
||||||
std::cout << " " << _("Network solution rate") << " | " << strprintf("~ 2^%.4f Sol/s", netsolpsLog) << std::endl;
|
std::cout << " " << _("Network solution rate") << " | " << DisplayHashRate(netsolps) << std::endl;
|
||||||
if (mining && miningTimer.running()) {
|
if (mining && miningTimer.running()) {
|
||||||
std::cout << " " << _("Local solution rate") << " | " << strprintf("~ 2^%.4f Sol/s", localsolpsLog) << std::endl;
|
std::cout << " " << _("Local solution rate") << " | " << DisplayHashRate(localsolps) << std::endl;
|
||||||
lines++;
|
lines++;
|
||||||
}
|
}
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
|
|
|
@ -74,6 +74,8 @@ double GetLocalSolPS();
|
||||||
int EstimateNetHeight(const Consensus::Params& params, int currentBlockHeight, int64_t currentBlockTime);
|
int EstimateNetHeight(const Consensus::Params& params, int currentBlockHeight, int64_t currentBlockTime);
|
||||||
boost::optional<int64_t> SecondsLeftToNextEpoch(const Consensus::Params& params, int currentHeight);
|
boost::optional<int64_t> SecondsLeftToNextEpoch(const Consensus::Params& params, int currentHeight);
|
||||||
std::string DisplayDuration(int64_t time, DurationFormat format);
|
std::string DisplayDuration(int64_t time, DurationFormat format);
|
||||||
|
std::string DisplaySize(size_t value);
|
||||||
|
std::string DisplayHashRate(double value);
|
||||||
|
|
||||||
void TriggerRefresh();
|
void TriggerRefresh();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue