From b38a02bd2400a62dfe76b9a0df9e74a48a39efaf Mon Sep 17 00:00:00 2001 From: ckolivas Date: Wed, 29 Jun 2011 11:14:16 +1000 Subject: [PATCH] Make the log time hash rate a rolling exponential average so it doesn't fluctuate so dramatically. --- cpu-miner.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cpu-miner.c b/cpu-miner.c index 5f597f83..43f004d1 100644 --- a/cpu-miner.c +++ b/cpu-miner.c @@ -533,6 +533,7 @@ static void hashmeter(int thr_id, struct timeval *diff, double total_secs; double local_secs; static double local_mhashes_done = 0; + static double rolling_local = 0; double local_mhashes = (double)hashes_done / 1000000.0; /* Don't bother calculating anything if we're not displaying it */ @@ -566,11 +567,14 @@ static void hashmeter(int thr_id, struct timeval *diff, return; gettimeofday(&total_tv_end, NULL); } + /* Use a rolling average by faking an exponential decay over 5 * log */ + rolling_local = ((rolling_local * 0.9) + local_mhashes_done) / 1.9; + timeval_subtract(&total_diff, &total_tv_end, &total_tv_start); total_secs = (double)total_diff.tv_sec + ((double)total_diff.tv_usec / 1000000.0); applog(LOG_INFO, "[%.2f | %.2f Mhash/s] [%d Accepted] [%d Rejected] [%d HW errors]", - local_mhashes_done / local_secs, + rolling_local / local_secs, total_mhashes_done / total_secs, accepted, rejected, hw_errors); local_mhashes_done = 0; }