Do not print too many decimals

This commit is contained in:
pooler 2012-03-21 23:41:48 +01:00
parent ed3d1c94f9
commit fc7dd5ead0

View file

@ -284,11 +284,12 @@ static bool submit_upstream_work(CURL *curl, struct work *work)
json_is_true(res) ? accepted_count++ : rejected_count++; json_is_true(res) ? accepted_count++ : rejected_count++;
pthread_mutex_unlock(&stats_lock); pthread_mutex_unlock(&stats_lock);
applog(LOG_INFO, "accepted: %lu/%lu (%.2f%%), %.2f khash/s %s", sprintf(s, hashrate >= 1e6 ? "%.0f" : "%.2f", 1e-3 * hashrate);
applog(LOG_INFO, "accepted: %lu/%lu (%.2f%%), %s khash/s %s",
accepted_count, accepted_count,
accepted_count + rejected_count, accepted_count + rejected_count,
100. * accepted_count / (accepted_count + rejected_count), 100. * accepted_count / (accepted_count + rejected_count),
1e-3 * hashrate, s,
json_is_true(res) ? "(yay!!!)" : "(booooo)"); json_is_true(res) ? "(yay!!!)" : "(booooo)");
json_decref(val); json_decref(val);
@ -584,9 +585,13 @@ static void *miner_thread(void *userdata)
hashes_done / (diff.tv_sec + 1e-6 * diff.tv_usec); hashes_done / (diff.tv_sec + 1e-6 * diff.tv_usec);
pthread_mutex_unlock(&stats_lock); pthread_mutex_unlock(&stats_lock);
} }
if (!opt_quiet) if (!opt_quiet) {
applog(LOG_INFO, "thread %d: %lu hashes, %.2f khash/s", char s[16];
thr_id, hashes_done, 1e-3 * thr_hashrates[thr_id]); sprintf(s, thr_hashrates[thr_id] >= 1e6 ? "%.0f" : "%.2f",
1e-3 * thr_hashrates[thr_id]);
applog(LOG_INFO, "thread %d: %lu hashes, %s khash/s",
thr_id, hashes_done, s);
}
/* if nonce found, submit work */ /* if nonce found, submit work */
if (rc && !submit_work(mythr, &work)) if (rc && !submit_work(mythr, &work))