From e1c84da07fdc0d44ed4d9875677628e71d60bfff Mon Sep 17 00:00:00 2001 From: Tanguy Pruvot Date: Wed, 12 Nov 2014 08:03:40 +0100 Subject: [PATCH] stats: fix multi gpu value + add average parameter (-N) --- configure.ac | 2 +- cpu-miner.c | 13 +++++++++++-- cpuminer-config.h | 6 +++--- stats.cpp | 8 ++++++-- 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/configure.ac b/configure.ac index ea8032b..674b2b6 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([ccminer], [1.4.7]) +AC_INIT([ccminer], [1.4.8]) AC_PREREQ([2.59c]) AC_CANONICAL_SYSTEM diff --git a/cpu-miner.c b/cpu-miner.c index c77a3a5..4180d19 100644 --- a/cpu-miner.c +++ b/cpu-miner.c @@ -235,6 +235,7 @@ static unsigned long accepted_count = 0L; static unsigned long rejected_count = 0L; static double *thr_hashrates; uint64_t global_hashrate = 0; +int opt_statsavg = 20; uint32_t opt_work_size = 0; /* default */ @@ -299,6 +300,7 @@ Options:\n\ -T, --timeout=N network timeout, in seconds (default: 270)\n\ -s, --scantime=N upper bound on time spent scanning current work when\n\ long polling is unavailable, in seconds (default: 5)\n\ + -N, --statsavg number of samples used to display hashrate (default: 20)\n\ --no-longpoll disable X-Long-Polling support\n\ --no-stratum disable X-Stratum support\n\ -q, --quiet disable per-thread hashmeter output\n\ @@ -328,7 +330,7 @@ static char const short_options[] = #ifdef HAVE_SYSLOG_H "S" #endif - "a:c:i:Dhp:Px:qr:R:s:t:T:o:u:O:Vd:f:mv:"; + "a:c:i:Dhp:Px:qr:R:s:t:T:o:u:O:Vd:f:mv:N:"; static struct option const options[] = { { "algo", 1, NULL, 'a' }, @@ -352,6 +354,7 @@ static struct option const options[] = { { "retries", 1, NULL, 'r' }, { "retry-pause", 1, NULL, 'R' }, { "scantime", 1, NULL, 's' }, + { "statsavg", 1, NULL, 'N' }, #ifdef HAVE_SYSLOG_H { "syslog", 0, NULL, 'S' }, #endif @@ -1566,7 +1569,7 @@ out: return NULL; } -#define PROGRAM_VERSION "1.4.7" +#define PROGRAM_VERSION "1.4.8" static void show_version_and_exit(void) { printf("%s v%s\n" @@ -1637,6 +1640,12 @@ static void parse_arg(int key, char *arg) case 'D': opt_debug = true; break; + case 'N': + v = atoi(arg); + if (v < 1) + opt_statsavg = INT_MAX; + opt_statsavg = v; + break; case 'q': opt_quiet = true; break; diff --git a/cpuminer-config.h b/cpuminer-config.h index 310b265..1767071 100644 --- a/cpuminer-config.h +++ b/cpuminer-config.h @@ -156,7 +156,7 @@ #define PACKAGE_NAME "ccminer" /* Define to the full name and version of this package. */ -#define PACKAGE_STRING "ccminer 1.4.7" +#define PACKAGE_STRING "ccminer 1.4.8" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "ccminer" @@ -165,7 +165,7 @@ #define PACKAGE_URL "" /* Define to the version of this package. */ -#define PACKAGE_VERSION "1.4.7" +#define PACKAGE_VERSION "1.4.8" /* If using the C implementation of alloca, define if you know the direction of stack growth for your system; otherwise it will be @@ -188,7 +188,7 @@ #define USE_XOP 1 /* Version number of package */ -#define VERSION "1.4.7" +#define VERSION "1.4.8" /* Define curl_free() as free() if our version of curl lacks curl_free. */ /* #undef curl_free */ diff --git a/stats.cpp b/stats.cpp index 26e9875..043eead 100644 --- a/stats.cpp +++ b/stats.cpp @@ -25,10 +25,11 @@ static std::map tlastscans; static uint64_t uid = 0; #define STATS_AVG_SAMPLES 20 -#define STATS_PURGE_TIMEOUT 5*60 +#define STATS_PURGE_TIMEOUT 180*60 /* 180 mn */ extern uint64_t global_hashrate; extern int opt_n_threads; +extern int opt_statsavg; extern int device_map[8]; /** @@ -75,7 +76,7 @@ extern "C" double stats_get_speed(int thr_id) int records = 0; std::map::reverse_iterator i = tlastscans.rbegin(); - while (i != tlastscans.rend() && records < STATS_AVG_SAMPLES) { + while (i != tlastscans.rend() && records < opt_statsavg) { if (!i->second.ignored) if (thr_id == -1 || (keypfx & i->first) == keypfx) { if (i->second.hashcount > 1000) { @@ -87,6 +88,9 @@ extern "C" double stats_get_speed(int thr_id) } if (records) speed /= (double)(records); + if (thr_id == -1) + speed *= (double)(opt_n_threads); + return speed; }