Make the output display the 5 second and total average Mhash/s. Make the log interval configurable.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
diff --git a/cpu-miner.c b/cpu-miner.c
index 24abeec..43b0610 100644
--- a/cpu-miner.c
+++ b/cpu-miner.c
@@ -119,6 +119,7 @@ bool use_syslog = false;
static bool opt_quiet = false;
static int opt_retries = 10;
static int opt_fail_pause = 30;
+static int opt_log_interval = 5;
int opt_scantime = 5;
static json_t *opt_config;
static const bool opt_time = true;
@@ -185,6 +186,9 @@ static struct option_help options_help[] = {
{ "intensity",
"(-I) Intensity of scanning (0 - 16, default 5)" },
+ { "log",
+ "(-l) Interval in seconds between log output (default 5)" },
+
{ "ndevs",
"(-n) Display number of detected GPUs" },
@@ -237,6 +241,7 @@ static struct option options[] = {
{ "debug", 0, NULL, 'D' },
{ "help", 0, NULL, 'h' },
{ "intensity", 1, NULL, 'I' },
+ { "log", 1, NULL, 'l' },
{ "ndevs", 0, NULL, 'n' },
{ "no-longpoll", 0, NULL, 1003 },
{ "pass", 1, NULL, 'p' },
@@ -507,9 +512,11 @@ static void hashmeter(int thr_id, struct timeval *diff,
struct timeval temp_tv_end, total_diff;
double khashes, secs;
double total_mhashes, total_secs;
+ double local_mhashes, local_secs;
+ static local_hashes_done = 0;
/* Don't bother calculating anything if we're not displaying it */
- if (opt_quiet)
+ if (opt_quiet || !opt_log_interval)
return;
khashes = hashes_done / 1000.0;
secs = (double)diff->tv_sec + ((double)diff->tv_usec / 1000000.0);
@@ -518,40 +525,39 @@ static void hashmeter(int thr_id, struct timeval *diff,
thr_id, hashes_done, hashes_done / secs);
gettimeofday(&temp_tv_end, NULL);
timeval_subtract(&total_diff, &temp_tv_end, &total_tv_end);
-
+ local_secs = (double)total_diff.tv_sec + ((double)total_diff.tv_usec / 1000000.0);
if (opt_n_threads + nDevs > 1) {
/* Totals are updated by all threads so can race without locking */
pthread_mutex_lock(&hash_lock);
total_hashes_done += hashes_done;
- if (total_diff.tv_sec < 5) {
- /* Only update the total every 5 seconds */
+ local_hashes_done += hashes_done;
+ if (total_diff.tv_sec < opt_log_interval) {
+ /* Only update the total every opt_log_interval seconds */
pthread_mutex_unlock(&hash_lock);
return;
}
gettimeofday(&total_tv_end, NULL);
pthread_mutex_unlock(&hash_lock);
- timeval_subtract(&total_diff, &total_tv_end, &total_tv_start);
- total_mhashes = total_hashes_done / 1000000.0;
- total_secs = (double)total_diff.tv_sec +
- ((double)total_diff.tv_usec / 1000000.0);
- applog(LOG_INFO, "[%.2f Mhash/sec] [%d Accepted] [%d Rejected]",
- total_mhashes / total_secs, accepted, rejected);
} else {
total_hashes_done += hashes_done;
+ local_hashes_done += hashes_done;
if (total_diff.tv_sec < 5) {
/* Only update the total every 5 seconds */
pthread_mutex_unlock(&hash_lock);
return;
}
gettimeofday(&total_tv_end, NULL);
- timeval_subtract(&total_diff, &total_tv_end, &total_tv_start);
- total_mhashes = total_hashes_done / 1000000.0;
- total_secs = (double)total_diff.tv_sec +
- ((double)total_diff.tv_usec / 1000000.0);
- applog(LOG_INFO, "[%.2f Mhash/sec] [%d Accepted] [%d Rejected]",
- total_mhashes / total_secs, accepted, rejected);
}
+ timeval_subtract(&total_diff, &total_tv_end, &total_tv_start);
+ total_mhashes = total_hashes_done / 1000000.0;
+ total_secs = (double)total_diff.tv_sec +
+ ((double)total_diff.tv_usec / 1000000.0);
+ local_mhashes = local_hashes_done / 1000000.0;
+ local_hashes_done = 0;
+ applog(LOG_INFO, "[%.2f | %.2f Mhash/s] [%d Accepted] [%d Rejected]",
+ local_mhashes / local_secs,
+ total_mhashes / total_secs, accepted, rejected);
}
static bool get_work(struct thr_info *thr, struct work *work)
@@ -1029,8 +1035,8 @@ static void parse_arg (int key, char *arg)
}
break;
}
- case 'q':
- opt_quiet = true;
+ case 'D':
+ opt_debug = true;
break;
case 'I':
v = atoi(arg);
@@ -1038,8 +1044,11 @@ static void parse_arg (int key, char *arg)
show_usage();
scan_intensity = v;
break;
- case 'D':
- opt_debug = true;
+ case 'l':
+ v = atoi(arg);
+ if (v < 0 || v > 9999) /* sanity check */
+ show_usage();
+ opt_log_interval = v;
break;
case 'p':
free(rpc_pass);
@@ -1048,6 +1057,9 @@ static void parse_arg (int key, char *arg)
case 'P':
opt_protocol = true;
break;
+ case 'q':
+ opt_quiet = true;
+ break;
case 'r':
v = atoi(arg);
if (v < -1 || v > 9999) /* sanity check */