API add 'MHS %ds' to 'summary'
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
diff --git a/API-README b/API-README
index 4b2ee51..2cff3db 100644
--- a/API-README
+++ b/API-README
@@ -502,6 +502,9 @@ API V1.31 (cgminer v3.6.3)
Added API command:
'lockstats' - display cgminer dev lock stats if compiled in
+Modified API command:
+ 'summary' - add 'MHS %ds' (where %d is the log interval)
+
---------
API V1.30 (cgminer v3.4.3)
diff --git a/api.c b/api.c
index 9bf87d5..7ece861 100644
--- a/api.c
+++ b/api.c
@@ -2568,6 +2568,9 @@ static void summary(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __mayb
root = api_add_elapsed(root, "Elapsed", &(total_secs), true);
root = api_add_mhs(root, "MHS av", &(mhs), false);
+ char mhsname[27];
+ sprintf(mhsname, "MHS %ds", opt_log_interval);
+ root = api_add_mhs(root, mhsname, &(total_rolling), false);
root = api_add_uint(root, "Found Blocks", &(found_blocks), true);
root = api_add_int(root, "Getworks", &(total_getworks), true);
root = api_add_int(root, "Accepted", &(total_accepted), true);
diff --git a/cgminer.c b/cgminer.c
index c43636c..7bc01b5 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -237,6 +237,7 @@ pthread_cond_t restart_cond;
pthread_cond_t gws_cond;
+double total_rolling;
double total_mhashes_done;
static struct timeval total_tv_start, total_tv_end;
@@ -4505,6 +4506,7 @@ void zero_stats(void)
int i;
cgtime(&total_tv_start);
+ total_rolling = 0;
total_mhashes_done = 0;
total_getworks = 0;
total_accepted = 0;
@@ -5003,7 +5005,6 @@ static void hashmeter(int thr_id, struct timeval *diff,
double secs;
double local_secs;
static double local_mhashes_done = 0;
- static double rolling = 0;
double local_mhashes;
bool showlog = false;
char displayed_hashes[16], displayed_rolling[16];
@@ -5076,15 +5077,15 @@ static void hashmeter(int thr_id, struct timeval *diff,
cgtime(&total_tv_end);
local_secs = (double)total_diff.tv_sec + ((double)total_diff.tv_usec / 1000000.0);
- decay_time(&rolling, local_mhashes_done / local_secs, local_secs);
- global_hashrate = roundl(rolling) * 1000000;
+ decay_time(&total_rolling, local_mhashes_done / local_secs, local_secs);
+ global_hashrate = roundl(total_rolling) * 1000000;
timersub(&total_tv_end, &total_tv_start, &total_diff);
total_secs = (double)total_diff.tv_sec +
((double)total_diff.tv_usec / 1000000.0);
dh64 = (double)total_mhashes_done / total_secs * 1000000ull;
- dr64 = (double)rolling * 1000000ull;
+ dr64 = (double)total_rolling * 1000000ull;
suffix_string(dh64, displayed_hashes, sizeof(displayed_hashes), 4);
suffix_string(dr64, displayed_rolling, sizeof(displayed_rolling), 4);
diff --git a/miner.h b/miner.h
index ceba175..9078aa1 100644
--- a/miner.h
+++ b/miner.h
@@ -1140,6 +1140,7 @@ extern struct pool **pools;
extern struct strategies strategies[];
extern enum pool_strategy pool_strategy;
extern int opt_rotate_period;
+extern double total_rolling;
extern double total_mhashes_done;
extern unsigned int new_blocks;
extern unsigned int found_blocks;