Re: [hackers] [ubase][PATCH] Add vmstat
I've never used vmstat before, but this looks pretty good overall and
seems to work well.
On 2019-10-05, Mattias Andrée <maandree_AT_kth.se> wrote:
> + goto beginning;
> + for (; argc && (argc < 2 || i < count); i++) {
Why not just set count = 1 when argc < 2?
> + clock_nanosleep(CLOCK_MONOTONIC, 0, &delay, NULL);
> + beginning:
> + load_vm(&vm[i & 1]);
> + print_vm(&vm[i & 1], &vm[~i & 1], active_mem, timestamp, one_header ? !i
> : (i % 50 == 0));
> + }
I think it might be a bit clearer to re-arrange the loop body to avoid
the labels and goto.
Something like
count = argc == 2 ? atoll(argv[1]) : 1;
for (;;) {
load_vm(&vm[i & 1]);
print_vm(&vm[i & 1], &vm[~i & 1], active_mem, timestamp, one_header
? !i : (i % 50 == 0));
if (++i == count)
break;
clock_nanosleep(CLOCK_MONOTONIC, 0, &delay, NULL);
}
Received on Sat Nov 02 2019 - 20:33:58 CET
This archive was generated by hypermail 2.3.0
: Mon Nov 04 2019 - 04:24:26 CET