Browse Source

Add utility hashrate to curses display

Luke Dashjr 13 years ago
parent
commit
be28cdbc36
2 changed files with 43 additions and 20 deletions
  1. 4 2
      README
  2. 39 18
      cgminer.c

+ 4 - 2
README

@@ -339,11 +339,12 @@ dedicated to this program,
 	http://forum.bitcoin.org/index.php?topic=28402.0
 	http://forum.bitcoin.org/index.php?topic=28402.0
 
 
 The output line shows the following:
 The output line shows the following:
-(5s):1713.6 (avg):1707.8 Mh/s | Q:301  A:729  R:8  HW:0  E:242%  U:22.53/m
+5s:1713.6 avg:1707.8 u:1710.2 Mh/s | Q:301  A:729  R:8  HW:0  E:242%  U:22.53/m
 
 
 Each column is as follows:
 Each column is as follows:
 5s:  A 5 second exponentially decaying average hash rate
 5s:  A 5 second exponentially decaying average hash rate
 avg: An all time average hash rate
 avg: An all time average hash rate
+u:   An all time average hash rate based on actual accepted shares
 Q:   The number of requested (Queued) work items from the pools
 Q:   The number of requested (Queued) work items from the pools
 A:   The number of Accepted shares
 A:   The number of Accepted shares
 R:   The number of Rejected shares
 R:   The number of Rejected shares
@@ -351,13 +352,14 @@ HW:  The number of HardWare errors
 E:   The Efficiency defined as number of shares returned / work item
 E:   The Efficiency defined as number of shares returned / work item
 U:   The Utility defined as the number of shares / minute
 U:   The Utility defined as the number of shares / minute
 
 
- GPU 1: 73.5C 2551RPM | 427.3/443.0Mh/s | A:8 R:0 HW:0 U:4.39/m
+ GPU 1: 73.5C 2551RPM | 427.3/443.0/442.1Mh/s | A:8 R:0 HW:0 U:4.39/m
 
 
 Each column is as follows:
 Each column is as follows:
 Temperature (if supported)
 Temperature (if supported)
 Fanspeed (if supported)
 Fanspeed (if supported)
 A 5 second exponentially decaying average hash rate
 A 5 second exponentially decaying average hash rate
 An all time average hash rate
 An all time average hash rate
+An all time average hash rate based on actual accepted shares
 The number of accepted shares
 The number of accepted shares
 The number of rejected shares
 The number of rejected shares
 The number of hardware erorrs
 The number of hardware erorrs

+ 39 - 18
cgminer.c

@@ -1351,6 +1351,12 @@ void tailsprintf(char *f, const char *fmt, ...)
 	va_end(ap);
 	va_end(ap);
 }
 }
 
 
+static float
+utility_to_hashrate(double utility)
+{
+	return utility * 0x4444444;
+}
+
 static const char*_unitchar = "kMGTPEZY?";
 static const char*_unitchar = "kMGTPEZY?";
 
 
 static void
 static void
@@ -1375,9 +1381,16 @@ enum h2bs_fmt {
 static const size_t h2bs_fmt_size[] = {6, 10, 11};
 static const size_t h2bs_fmt_size[] = {6, 10, 11};
 
 
 static char*
 static char*
-hashrate_to_bufstr(char*buf, float hashrate, unsigned char unit, enum h2bs_fmt fmt)
+hashrate_to_bufstr(char*buf, float hashrate, signed char unitin, enum h2bs_fmt fmt)
 {
 {
-	unsigned char prec, i, ucp;
+	unsigned char prec, i, ucp, unit;
+	if (unitin == -1)
+	{
+		unit = 0;
+		hashrate_pick_unit(hashrate, &unit);
+	}
+	else
+		unit = unitin;
 	
 	
 	i = 5;
 	i = 5;
 	switch (fmt) {
 	switch (fmt) {
@@ -1406,15 +1419,17 @@ hashrate_to_bufstr(char*buf, float hashrate, unsigned char unit, enum h2bs_fmt f
 }
 }
 
 
 static void
 static void
-dual_hashrate_sstr(char**out, float current, float average, enum h2bs_fmt longfmt)
+ti_hashrate_bufstr(char**out, float current, float average, float sharebased, enum h2bs_fmt longfmt)
 {
 {
-	char *bufA = out[0], *bufB = out[1];
 	unsigned char unit = 0;
 	unsigned char unit = 0;
 	
 	
 	hashrate_pick_unit(current, &unit);
 	hashrate_pick_unit(current, &unit);
 	hashrate_pick_unit(average, &unit);
 	hashrate_pick_unit(average, &unit);
-	hashrate_to_bufstr(bufA, current, unit, H2B_NOUNIT);
-	hashrate_to_bufstr(bufB, average, unit, longfmt);
+	hashrate_pick_unit(sharebased, &unit);
+	
+	hashrate_to_bufstr(out[0], current, unit, H2B_NOUNIT);
+	hashrate_to_bufstr(out[1], average, unit, H2B_NOUNIT);
+	hashrate_to_bufstr(out[2], sharebased, unit, longfmt);
 }
 }
 
 
 static void get_statline(char *buf, struct cgpu_info *cgpu)
 static void get_statline(char *buf, struct cgpu_info *cgpu)
@@ -1424,15 +1439,17 @@ static void get_statline(char *buf, struct cgpu_info *cgpu)
 		cgpu->api->get_statline_before(buf, cgpu);
 		cgpu->api->get_statline_before(buf, cgpu);
 	else
 	else
 		tailsprintf(buf, "               | ");
 		tailsprintf(buf, "               | ");
-	char cHr[h2bs_fmt_size[H2B_NOUNIT]], aHr[h2bs_fmt_size[H2B_SPACED]];
-	dual_hashrate_sstr(
-		(char*[2]){cHr, aHr},
+	char cHr[h2bs_fmt_size[H2B_NOUNIT]], aHr[h2bs_fmt_size[H2B_NOUNIT]], uHr[h2bs_fmt_size[H2B_SPACED]];
+	ti_hashrate_bufstr(
+		(char*[]){cHr, aHr, uHr},
 		1e6*cgpu->rolling,
 		1e6*cgpu->rolling,
 		1e6*cgpu->total_mhashes / total_secs,
 		1e6*cgpu->total_mhashes / total_secs,
+		utility_to_hashrate(cgpu->utility),
 		H2B_SPACED);
 		H2B_SPACED);
-	tailsprintf(buf, "(%ds):%s (avg):%s | A:%d R:%d HW:%d U:%.1f/m",
+	tailsprintf(buf, "%ds:%s avg:%s u:%s | A:%d R:%d HW:%d U:%.1f/m",
 		opt_log_interval,
 		opt_log_interval,
 		cHr, aHr,
 		cHr, aHr,
+		uHr,
 		cgpu->accepted,
 		cgpu->accepted,
 		cgpu->rejected,
 		cgpu->rejected,
 		cgpu->hw_errors,
 		cgpu->hw_errors,
@@ -1514,11 +1531,12 @@ static void curses_print_devstatus(int thr_id)
 	else
 	else
 		wprintw(statuswin, "               | ");
 		wprintw(statuswin, "               | ");
 
 
-	char cHr[h2bs_fmt_size[H2B_NOUNIT]], aHr[h2bs_fmt_size[H2B_SHORT]];
-	dual_hashrate_sstr(
-		(char*[2]){cHr, aHr},
+	char cHr[h2bs_fmt_size[H2B_NOUNIT]], aHr[h2bs_fmt_size[H2B_NOUNIT]], uHr[h2bs_fmt_size[H2B_SHORT]];
+	ti_hashrate_bufstr(
+		(char*[]){cHr, aHr, uHr},
 		1e6*cgpu->rolling,
 		1e6*cgpu->rolling,
 		1e6*cgpu->total_mhashes / total_secs,
 		1e6*cgpu->total_mhashes / total_secs,
+		utility_to_hashrate(cgpu->utility),
 		H2B_SHORT);
 		H2B_SHORT);
 	if (cgpu->status == LIFE_DEAD)
 	if (cgpu->status == LIFE_DEAD)
 		wprintw(statuswin, "DEAD ");
 		wprintw(statuswin, "DEAD ");
@@ -1534,8 +1552,9 @@ static void curses_print_devstatus(int thr_id)
 	adj_width(cgpu->rejected, &rwidth);
 	adj_width(cgpu->rejected, &rwidth);
 	adj_width(cgpu->hw_errors, &hwwidth);
 	adj_width(cgpu->hw_errors, &hwwidth);
 	adj_width(cgpu->utility, &uwidth);
 	adj_width(cgpu->utility, &uwidth);
-	wprintw(statuswin, "/%s | A:%*d R:%*d HW:%*d U:%*.2f/m",
+	wprintw(statuswin, "/%s/%s | A:%*d R:%*d HW:%*d U:%*.2f/m",
 			aHr,
 			aHr,
+			uHr,
 			awidth, cgpu->accepted,
 			awidth, cgpu->accepted,
 			rwidth, cgpu->rejected,
 			rwidth, cgpu->rejected,
 			hwwidth, cgpu->hw_errors,
 			hwwidth, cgpu->hw_errors,
@@ -3459,7 +3478,7 @@ static void hashmeter(int thr_id, struct timeval *diff,
 	static double rolling = 0;
 	static double rolling = 0;
 	double local_mhashes = (double)hashes_done / 1000000.0;
 	double local_mhashes = (double)hashes_done / 1000000.0;
 	bool showlog = false;
 	bool showlog = false;
-	char cHr[h2bs_fmt_size[H2B_NOUNIT]], aHr[h2bs_fmt_size[H2B_SPACED]];
+	char cHr[h2bs_fmt_size[H2B_NOUNIT]], aHr[h2bs_fmt_size[H2B_NOUNIT]], uHr[h2bs_fmt_size[H2B_SPACED]];
 
 
 	/* Update the last time this thread reported in */
 	/* Update the last time this thread reported in */
 	if (thr_id >= 0) {
 	if (thr_id >= 0) {
@@ -3536,15 +3555,17 @@ static void hashmeter(int thr_id, struct timeval *diff,
 	utility = total_accepted / ( total_secs ? total_secs : 1 ) * 60;
 	utility = total_accepted / ( total_secs ? total_secs : 1 ) * 60;
 	efficiency = total_getworks ? total_accepted * 100.0 / total_getworks : 0.0;
 	efficiency = total_getworks ? total_accepted * 100.0 / total_getworks : 0.0;
 
 
-	dual_hashrate_sstr(
-		(char*[2]){cHr, aHr},
+	ti_hashrate_bufstr(
+		(char*[]){cHr, aHr, uHr},
 		1e6*rolling,
 		1e6*rolling,
 		1e6*total_mhashes_done / total_secs,
 		1e6*total_mhashes_done / total_secs,
+		utility_to_hashrate(utility),
 		H2B_SPACED);
 		H2B_SPACED);
-	sprintf(statusline, "%s(%ds):%s (avg):%s | Q:%d  A:%d  R:%d  HW:%d  E:%.0f%%  U:%.1f/m",
+	sprintf(statusline, "%s%ds:%s avg:%s u:%s | Q:%d  A:%d  R:%d  HW:%d  E:%.0f%%  U:%.1f/m",
 		want_per_device_stats ? "ALL " : "",
 		want_per_device_stats ? "ALL " : "",
 		opt_log_interval,
 		opt_log_interval,
 		cHr, aHr,
 		cHr, aHr,
+		uHr,
 		total_getworks, total_accepted, total_rejected, hw_errors, efficiency, utility);
 		total_getworks, total_accepted, total_rejected, hw_errors, efficiency, utility);