Commit 17690d40 authored by Nils Goroll's avatar Nils Goroll Committed by Pål Hermunn Johansen

refresh period: missing option, sub-second, allow inc/dec

Actually implement the documented -p option

Make the update delay a double to allow update frequencies of less
than a second.

Add + and - keys to the curses interface to update the refresh
frequency while running.

Show update frequency in the top line.
parent a63e2b09
......@@ -68,7 +68,7 @@ static int hist_buckets;
static pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER;
static int end_of_file = 0;
static int delay = 1;
static double delay = 1;
static unsigned rr_hist[HIST_N];
static unsigned nhist;
static unsigned next_hist;
......@@ -218,7 +218,7 @@ update(void)
/* nothing */ ;
scale = scales[i];
mvprintw(0, 0, "1:%d, n = %d", scale, nhist);
mvprintw(0, 0, "1:%d, n = %d, d = %g", scale, nhist, delay);
for (j = 2; j < LINES - 3; j+=5)
mvprintw(j, 0, "%d_", (LINES - 3 - j) * scale);
......@@ -395,6 +395,14 @@ do_curses(void *arg)
case '9':
delay = 1 << (ch - '0');
break;
case '+':
delay /= 2;
if (delay < 1e-3)
delay = 1e-3;
break;
case '-':
delay *= 2;
break;
default:
beep();
break;
......@@ -445,6 +453,13 @@ main(int argc, char **argv)
case 'h':
/* Usage help */
usage(0);
case 'p':
delay = strtod(optarg, NULL);
if (delay <= 0) {
fprintf(stderr, "-p: invalid '%s'\n", optarg);
exit(1);
}
break;
case 'P':
colon = strchr(optarg, ':');
/* no colon, take the profile as a name*/
......
......@@ -41,7 +41,8 @@
VOPT("p:", "[-p period]", "Refresh period", \
"Specified the number of seconds between screen refreshes." \
" Default is 1 second, and can be changed at runtime by" \
" pressing the [1-9] keys." \
" pressing the [0-9] keys (powers of 2 in seconds" \
" or + and - (double/halve the speed)" \
)
#define HIS_OPT_P \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment