From c815de4991a8b880851e10cf553c41dd4bb731b2 Mon Sep 17 00:00:00 2001 From: Marco Fontani Date: Tue, 5 Jul 2011 08:29:13 +0100 Subject: [PATCH] Add "efficiency" and "utility" Efficiency is the percentage of getworks compared to the amount of work requested from the pool. It can go higher than 100% in case more shares than getworks were found. Some pools prefer miners to have a high efficiency; CPU miners likely exhibit a low efficiency. Utility is the number of shares found per minute, since the miner was started. It is another way to describe the effectiveness of a miner. --- main.c | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/main.c b/main.c index a783eaca..8f5f85bc 100644 --- a/main.c +++ b/main.c @@ -154,11 +154,12 @@ static struct timeval total_tv_start, total_tv_end; static int accepted, rejected; int hw_errors; static int total_queued; +static unsigned int getwork_requested = 0; static void applog_and_exit(const char *fmt, ...) { va_list ap; - + va_start(ap, fmt); vapplog(LOG_ERR, fmt, ap); va_end(ap); @@ -484,6 +485,7 @@ static bool submit_upstream_work(const struct work *work) bool rc = false; struct cgpu_info *cgpu = thr_info[work->thr_id].cgpu; CURL *curl = curl_easy_init(); + double utility, efficiency; if (unlikely(!curl)) { applog(LOG_ERR, "CURL initialisation failed"); @@ -530,13 +532,19 @@ static bool submit_upstream_work(const struct work *work) applog(LOG_DEBUG, "PROOF OF WORK RESULT: false (booooo)"); printf("[Rejected] "); } + + utility = accepted / ( total_secs ? total_secs : 1 ) * 60; + efficiency = getwork_requested ? cgpu->accepted * 100.0 / getwork_requested : 0.0; + if (!opt_quiet) { - printf("[%sPU: %d] [Rate: %.2f Mhash/s] [Accepted: %d Rejected: %d HW errors: %d] \n", - cgpu->is_gpu? "G" : "C", cgpu->cpu_gpu, cgpu->total_mhashes / total_secs, - cgpu->accepted, cgpu->rejected, cgpu->hw_errors); + printf("[%sPU: %d] [Rate: %.2f Mhash/s] [Requested: %d Accepted: %d Rejected: %d HW errors: %d Efficiency: %.3f%% Utility: %.2f/m] \n", + cgpu->is_gpu? "G" : "C", cgpu->cpu_gpu, cgpu->total_mhashes / total_secs, + getwork_requested, cgpu->accepted, cgpu->rejected, cgpu->hw_errors, + efficiency, utility); } - applog(LOG_INFO, "%sPU: %d Accepted: %d Rejected: %d HW errors: %d", - cgpu->is_gpu? "G" : "C", cgpu->cpu_gpu, cgpu->accepted, cgpu->rejected, cgpu->hw_errors); + applog(LOG_INFO, "%sPU: %d Requested: %d Accepted: %d Rejected: %d HW errors: %d efficiency: %.3f%% utility: %.2f/m", + cgpu->is_gpu? "G" : "C", cgpu->cpu_gpu, getwork_requested, cgpu->accepted, cgpu->rejected, cgpu->hw_errors, efficiency, utility + ); json_decref(val); @@ -757,6 +765,7 @@ static void hashmeter(int thr_id, struct timeval *diff, struct timeval temp_tv_end, total_diff; double khashes, secs; double local_secs; + double utility, efficiency = 0.0; static double local_mhashes_done = 0; static double rolling_local = 0; double local_mhashes = (double)hashes_done / 1000000.0; @@ -798,13 +807,18 @@ static void hashmeter(int thr_id, struct timeval *diff, timeval_subtract(&total_diff, &total_tv_end, &total_tv_start); total_secs = (double)total_diff.tv_sec + ((double)total_diff.tv_usec / 1000000.0); - printf("[Rate (%ds): %.2f (avg): %.2f Mhash/s] [Accepted: %d Rejected: %d HW errors: %d] \r", - opt_log_interval, rolling_local / local_secs, total_mhashes_done / total_secs, - accepted, rejected, hw_errors); + + utility = accepted / ( total_secs ? total_secs : 1 ) * 60; + efficiency = getwork_requested ? accepted * 100.0 / getwork_requested : 0.0; + + printf("[Rate (%ds): %.2f (avg): %.2f Mhash/s] [Requested: %d Accepted: %d Rejected: %d HW errors: %d Efficiency: %.2f%% Utility: %.2f/m]\r", + opt_log_interval, rolling_local / local_secs, total_mhashes_done / total_secs, + getwork_requested, accepted, rejected, hw_errors, efficiency, utility); fflush(stdout); - applog(LOG_INFO, "[Rate (%ds): %.2f (avg): %.2f Mhash/s] [Accepted: %d Rejected: %d HW errors: %d]", - opt_log_interval, rolling_local / local_secs, total_mhashes_done / total_secs, - accepted, rejected, hw_errors); + applog(LOG_INFO, "[Rate (%ds): %.2f (avg): %.2f Mhash/s] [Requested: %d Accepted: %d Rejected: %d HW errors: %d Efficiency: %.2f%% Utility: %.2f/m]", + opt_log_interval, rolling_local / local_secs, total_mhashes_done / total_secs, + getwork_requested, accepted, rejected, hw_errors, efficiency, utility); + local_mhashes_done = 0; out_unlock: pthread_mutex_unlock(&hash_lock); @@ -1275,6 +1289,8 @@ static void *gpuminer_thread(void *userdata) work->thr_id = thr_id; requested = false; + getwork_requested++; + precalc_hash(&work->blk, (uint32_t *)(work->midstate), (uint32_t *)(work->data + 64)); work->blk.nonce = 0; work_restart[thr_id].restart = 0;