I've never used vmstat before, but this looks pretty good overall and seems to work well.
On 2019-10-05, Mattias Andrée <[email protected]> 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); }
