Browse Source

Add network bandwidth rate to TUI

Luke Dashjr 12 years ago
parent
commit
4aaa12dad5
2 changed files with 34 additions and 2 deletions
  1. 2 1
      README
  2. 32 1
      miner.c

+ 2 - 1
README

@@ -405,13 +405,14 @@ R:   The number of Rejected shares, stale shares discarded (never submitted),
 HW:  The number of HardWare errors, and percentage invalid of nonces returned
 
 The BFGMiner status line shows:
- ST: 1  GF: 1  NB: 1  AS: 0  RF: 1  E: 2.42  U:22.53/m  BS:2.71k
+ ST: 1  GF: 1  NB: 1  AS: 0  RF: 1  BW:  75/241 B/s  E: 2.42  U:22.53/m  BS:2.71k
 
 ST is STaged work items (ready to use).
 GF is Getwork Fail Occasions (server slow to provide work)
 NB is New Blocks detected on the network
 AS is Active Submissions (shares in the process of submitting)
 RF is Remote Fail occasions (server slow to accept work)
+BW is BandWidth usage on the network
 E  is Efficiency defined as number of shares accepted (multiplied by their
           difficulty) per 2 KB of bandwidth
 U  is Utility defined as the number of shares / minute

+ 32 - 1
miner.c

@@ -2698,12 +2698,16 @@ static void curses_print_status(void)
 
 	utility = total_accepted / total_secs * 60;
 
-	mvwprintw(statuswin, 3, 0, " ST: %d  GF: %d  NB: %d  AS: %d  RF: %d  E: %.2f  U:%.1f/m  BS:%s",
+	char bwstr[12];
+	mvwprintw(statuswin, 3, 0, " ST: %d  GF: %d  NB: %d  AS: %d  RF: %d  BW: %s  E: %.2f  U:%.1f/m  BS:%s",
 		total_staged(),
 		total_go,
 		new_blocks,
 		total_submitting,
 		total_ro,
+		multi_format_unit(bwstr, false, "B/s", H2B_SHORT, "/", 2,
+		                  (float)(total_bytes_rcvd / total_secs),
+		                  (float)(total_bytes_sent / total_secs)),
 		efficiency,
 		utility,
 		best_share);
@@ -5177,6 +5181,8 @@ static bool input_pool(bool live);
 static void display_pool_summary(struct pool *pool)
 {
 	double efficiency = 0.0;
+	char xfer[17], bw[19];
+	int pool_secs;
 
 	if (curses_active_locked()) {
 		wlog("Pool: %s\n", pool->rpc_url);
@@ -5192,6 +5198,14 @@ static void display_pool_summary(struct pool *pool)
 		);
 		wlog(" Accepted difficulty shares: %1.f\n", pool->diff_accepted);
 		wlog(" Rejected difficulty shares: %1.f\n", pool->diff_rejected);
+		pool_secs = timer_elapsed(&pool->cgminer_stats.start_tv, NULL);
+		wlog(" Network transfer: %s  (%s)\n",
+		     multi_format_unit(xfer, true, "B", H2B_SPACED, " / ", 2,
+		                       (float)pool->cgminer_pool_stats.net_bytes_received,
+		                       (float)pool->cgminer_pool_stats.net_bytes_sent),
+		     multi_format_unit(bw, true, "B/s", H2B_SPACED, " / ", 2,
+		                       (float)(pool->cgminer_pool_stats.net_bytes_received / pool_secs),
+		                       (float)(pool->cgminer_pool_stats.net_bytes_sent / pool_secs)));
 		uint64_t pool_bytes_xfer = pool->cgminer_pool_stats.net_bytes_received + pool->cgminer_pool_stats.net_bytes_sent;
 		efficiency = pool_bytes_xfer ? pool->diff_accepted * 2048. / pool_bytes_xfer : 0.0;
 		wlog(" Efficiency (accepted * difficulty / 2 KB): %.2f\n", efficiency);
@@ -8373,6 +8387,8 @@ void print_summary(void)
 	struct timeval diff;
 	int hours, mins, secs, i;
 	double utility, efficiency = 0.0;
+	char xfer[17], bw[19];
+	int pool_secs;
 
 	timersub(&total_tv_end, &total_tv_start, &diff);
 	hours = diff.tv_sec / 3600;
@@ -8403,6 +8419,13 @@ void print_summary(void)
 	applog(LOG_WARNING, "Accepted difficulty shares: %1.f", total_diff_accepted);
 	applog(LOG_WARNING, "Rejected difficulty shares: %1.f", total_diff_rejected);
 	applog(LOG_WARNING, "Hardware errors: %d", hw_errors);
+	applog(LOG_WARNING, "Network transfer: %s  (%s)",
+	       multi_format_unit(xfer, true, "B", H2B_SPACED, " / ", 2,
+	                         (float)total_bytes_rcvd,
+	                         (float)total_bytes_sent),
+	       multi_format_unit(bw, true, "B/s", H2B_SPACED, " / ", 2,
+	                         (float)(total_bytes_rcvd / total_secs),
+	                         (float)(total_bytes_sent / total_secs)));
 	applog(LOG_WARNING, "Efficiency (accepted shares * difficulty / 2 KB): %.2f", efficiency);
 	applog(LOG_WARNING, "Utility (accepted shares / min): %.2f/min\n", utility);
 
@@ -8426,6 +8449,14 @@ void print_summary(void)
 			);
 			applog(LOG_WARNING, " Accepted difficulty shares: %1.f", pool->diff_accepted);
 			applog(LOG_WARNING, " Rejected difficulty shares: %1.f", pool->diff_rejected);
+			pool_secs = timer_elapsed(&pool->cgminer_stats.start_tv, NULL);
+			applog(LOG_WARNING, " Network transfer: %s  (%s)",
+			       multi_format_unit(xfer, true, "B", H2B_SPACED, " / ", 2,
+			                         (float)pool->cgminer_pool_stats.net_bytes_received,
+			                         (float)pool->cgminer_pool_stats.net_bytes_sent),
+			       multi_format_unit(bw, true, "B/s", H2B_SPACED, " / ", 2,
+			                         (float)(pool->cgminer_pool_stats.net_bytes_received / pool_secs),
+			                         (float)(pool->cgminer_pool_stats.net_bytes_sent / pool_secs)));
 			uint64_t pool_bytes_xfer = pool->cgminer_pool_stats.net_bytes_received + pool->cgminer_pool_stats.net_bytes_sent;
 			efficiency = pool_bytes_xfer ? pool->diff_accepted * 2048. / pool_bytes_xfer : 0.0;
 			applog(LOG_WARNING, " Efficiency (accepted * difficulty / 2 KB): %.2f", efficiency);