diff --git a/api.c b/api.c index 7eb684dc..078c1579 100644 --- a/api.c +++ b/api.c @@ -2114,11 +2114,12 @@ static int itemstats(int i, char *id, struct cgminer_stats *stats, struct cgmine if (pool_stats) { sprintf(buf, isjson ? ",\"Pool Calls\":%d,\"Pool Attempts\":%d,\"Pool Wait\":%ld.%06ld,\"Pool Max\":%ld.%06ld,\"Pool Min\":%ld.%06ld" - : ",Pool Calls=%d,Pool Attempts=%d,Pool Wait=%ld.%06ld,Pool Max=%ld.%06ld,Pool Min=%ld.%06ld", + : ",Pool Calls=%d,Pool Attempts=%d,Pool Wait=%ld.%06ld,Pool Max=%ld.%06ld,Pool Min=%ld.%06ld,Pool Av=%f", pool_stats->getwork_calls, pool_stats->getwork_attempts, pool_stats->getwork_wait.tv_sec, pool_stats->getwork_wait.tv_usec, pool_stats->getwork_wait_max.tv_sec, pool_stats->getwork_wait_max.tv_usec, - pool_stats->getwork_wait_min.tv_sec, pool_stats->getwork_wait_min.tv_usec); + pool_stats->getwork_wait_min.tv_sec, pool_stats->getwork_wait_min.tv_usec, + pool_stats->getwork_wait_rolling); strcat(io_buffer, buf); } diff --git a/cgminer.c b/cgminer.c index 9384a167..c7a6d39d 100644 --- a/cgminer.c +++ b/cgminer.c @@ -1856,13 +1856,11 @@ retry: if (!rc && retries < 3) goto retry; - work->pool = pool; - work->longpoll = false; - total_getworks++; - pool->getwork_requested++; - gettimeofday(&tv_end, NULL); timersub(&tv_end, &tv_start, &tv_elapsed); + pool_stats->getwork_wait_rolling += ((double)tv_elapsed.tv_sec + ((double)tv_elapsed.tv_usec / 1000000)) * 0.63; + pool_stats->getwork_wait_rolling /= 1.63; + timeradd(&tv_elapsed, &(pool_stats->getwork_wait), &(pool_stats->getwork_wait)); if (timercmp(&tv_elapsed, &(pool_stats->getwork_wait_max), >)) { pool_stats->getwork_wait_max.tv_sec = tv_elapsed.tv_sec; @@ -1874,6 +1872,11 @@ retry: } pool_stats->getwork_calls++; + work->pool = pool; + work->longpoll = false; + total_getworks++; + pool->getwork_requested++; + json_decref(val); out: diff --git a/miner.h b/miner.h index b1840e98..9eb1b6d8 100644 --- a/miner.h +++ b/miner.h @@ -298,6 +298,7 @@ struct cgminer_pool_stats { struct timeval getwork_wait; struct timeval getwork_wait_max; struct timeval getwork_wait_min; + double getwork_wait_rolling; }; struct cgpu_info {