mirror of
https://github.com/GOSTSec/ccminer
synced 2025-02-05 11:24:22 +00:00
hashrate: Remove some extra units and allow 4 digits
to keep current X11 output (sample: 2950.01 kH/s)
This commit is contained in:
parent
c41d9e7bb6
commit
81fd04a208
@ -528,7 +528,7 @@ static void calc_diff(struct work *work, int known)
|
||||
|
||||
static int share_result(int result, const char *reason)
|
||||
{
|
||||
char s[345];
|
||||
char s[32] = { 0 };
|
||||
double hashrate = 0.;
|
||||
|
||||
pthread_mutex_lock(&stats_lock);
|
||||
@ -542,8 +542,8 @@ static int share_result(int result, const char *reason)
|
||||
|
||||
global_hashrate = llround(hashrate);
|
||||
|
||||
sprintf(s, hashrate >= 1e6 ? "%.0f" : "%.2f", 1e-3 * hashrate);
|
||||
applog(LOG_NOTICE, "accepted: %lu/%lu (%.2f%%), %s khash/s %s",
|
||||
format_hashrate(hashrate, s);
|
||||
applog(LOG_NOTICE, "accepted: %lu/%lu (%.2f%%), %s %s",
|
||||
accepted_count,
|
||||
accepted_count + rejected_count,
|
||||
100. * accepted_count / (accepted_count + rejected_count),
|
||||
|
41
util.cpp
41
util.cpp
@ -175,54 +175,31 @@ void get_defconfig_path(char *out, size_t bufsize, char *argv0)
|
||||
|
||||
void format_hashrate(double hashrate, char *output)
|
||||
{
|
||||
char prefix;
|
||||
char prefix = '\0';
|
||||
|
||||
if (hashrate < 1e3)
|
||||
prefix = ' ';
|
||||
else if (hashrate < 1e6)
|
||||
{
|
||||
if (hashrate < 10000) {
|
||||
// nop
|
||||
}
|
||||
else if (hashrate < 1e7) {
|
||||
prefix = 'k';
|
||||
hashrate *= 1e-3;
|
||||
}
|
||||
else if (hashrate < 1e9)
|
||||
{
|
||||
else if (hashrate < 1e10) {
|
||||
prefix = 'M';
|
||||
hashrate *= 1e-6;
|
||||
}
|
||||
else if (hashrate < 1e12)
|
||||
{
|
||||
else if (hashrate < 1e13) {
|
||||
prefix = 'G';
|
||||
hashrate *= 1e-9;
|
||||
}
|
||||
else if (hashrate < 1e15)
|
||||
{
|
||||
else {
|
||||
prefix = 'T';
|
||||
hashrate *= 1e-12;
|
||||
}
|
||||
else if (hashrate < 1e18)
|
||||
{
|
||||
prefix = 'P';
|
||||
hashrate *= 1e-15;
|
||||
}
|
||||
else if (hashrate < 1e21)
|
||||
{
|
||||
prefix = 'E';
|
||||
hashrate *= 1e-18;
|
||||
}
|
||||
else if (hashrate < 1e24)
|
||||
{
|
||||
prefix = 'Z';
|
||||
hashrate *= 1e-21;
|
||||
}
|
||||
else
|
||||
{
|
||||
prefix = 'Y';
|
||||
hashrate *= 1e-24;
|
||||
}
|
||||
|
||||
sprintf(
|
||||
output,
|
||||
prefix == ' ' ? "%.0f%cH/s" : "%.2f %cH/s",
|
||||
prefix ? "%.2f %cH/s" : "%.2f H/s%c",
|
||||
hashrate, prefix
|
||||
);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user