From 83ccbf6b89671803eb2d805b1f86eed387fe4018 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Fri, 18 Nov 2016 16:32:21 +1300 Subject: [PATCH] Add -metricsrefreshtime option --- src/metrics.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/metrics.cpp b/src/metrics.cpp index c20ce47d5..285f1f653 100644 --- a/src/metrics.cpp +++ b/src/metrics.cpp @@ -249,7 +249,9 @@ void ThreadShowMetricsScreen() RenameThread("zcash-metrics-screen"); // Determine whether we should render a persistent UI or rolling metrics - bool isScreen = GetBoolArg("-metricsui", isatty(STDOUT_FILENO)); + bool isTTY = isatty(STDOUT_FILENO); + bool isScreen = GetBoolArg("-metricsui", isTTY); + int64_t nRefresh = GetArg("-metricsrefreshtime", isTTY ? 1 : 600); if (isScreen) { // Clear screen @@ -274,7 +276,7 @@ void ThreadShowMetricsScreen() int cols = 80; // Get current window size - if (isatty(STDOUT_FILENO)) { + if (isTTY) { struct winsize w; w.ws_col = 0; if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &w) != -1 && w.ws_col != 0) { @@ -306,8 +308,11 @@ void ThreadShowMetricsScreen() std::cout << "----------------" << std::endl; } - boost::this_thread::interruption_point(); - MilliSleep(1000); + int64_t nWaitEnd = GetTime() + nRefresh; + while (GetTime() < nWaitEnd) { + boost::this_thread::interruption_point(); + MilliSleep(200); + } if (isScreen) { // Return to the top of the updating section