From e4700f2e2bdb3f8a801ad91fcb86f7cfe563a98e Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Sat, 29 Oct 2011 16:52:37 +0000 Subject: [PATCH] Patch by Philippe Saint-Pierre: Wait only half a second instead of 5 before displaying anything. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42969 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/bin/top.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/bin/top.c b/src/bin/top.c index eed4ae153f..090bf177df 100644 --- a/src/bin/top.c +++ b/src/bin/top.c @@ -443,11 +443,7 @@ main(int argc, char **argv) refresh = 0; } } - if (iters < 0) { - printf("Starting: infinite intervals of %d second%s each\n", - interval, - (interval == 1) ? "" : "s"); - } else { + if (iters >= 0) { printf("Starting: %d interval%s of %d second%s each\n", iters, (iters == 1) ? "" : "s", interval, (interval == 1) ? "" : "s"); @@ -456,8 +452,21 @@ main(int argc, char **argv) signal(SIGWINCH, winch_handler); then = system_time(); + if (iters < 0) { + // You will only have to wait half a second for the first iteration. + uinterval = 1 * 1000000 / 2; + baseline = gather(NULL, &busy, 0, refresh); + elapsed = system_time() - then; + if (elapsed < uinterval) { + snooze(uinterval - elapsed); + elapsed = uinterval; + } + then = system_time(); + baseline = gather(&baseline, &busy, elapsed, refresh); + } else + baseline = gather(NULL, &busy, 0, refresh); + uinterval = interval * 1000000; - baseline = gather(NULL, &busy, 0, refresh); for (i = 0; iters < 0 || i < iters; i++) { elapsed = system_time() - then; if (elapsed < uinterval) {