From 4fd1ef63836ffdd0b89e183d177fae0f670d3aef Mon Sep 17 00:00:00 2001 From: pooler Date: Sat, 4 Aug 2012 00:14:26 +0200 Subject: [PATCH] Add duration of getwork requests to debug output --- cpu-miner.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/cpu-miner.c b/cpu-miner.c index e813aaf..e0acebd 100644 --- a/cpu-miner.c +++ b/cpu-miner.c @@ -347,14 +347,24 @@ static bool get_upstream_work(CURL *curl, struct work *work) { json_t *val; bool rc; + struct timeval tv_start, tv_end, diff; + gettimeofday(&tv_start, NULL); val = json_rpc_call(curl, rpc_url, rpc_userpass, rpc_req, want_longpoll, false, NULL); + gettimeofday(&tv_end, NULL); + if (!val) return false; rc = work_decode(json_object_get(val, "result"), work); + if (opt_debug && rc) { + timeval_subtract(&diff, &tv_end, &tv_start); + applog(LOG_DEBUG, "DEBUG: got new work in %d ms", + diff.tv_sec * 1000 + diff.tv_usec / 1000); + } + json_decref(val); return rc; @@ -573,8 +583,6 @@ static void *miner_thread(void *userdata) goto out; } time(&g_work_time); - if (opt_debug) - applog(LOG_DEBUG, "DEBUG: got new work"); } if (memcmp(work.data, g_work.data, 76)) { memcpy(&work, &g_work, sizeof(struct work));