Ticket #4328: patch_top.diff
File patch_top.diff, 1.2 KB (added by , 13 years ago) |
---|
-
src/bin/top.c
443 443 refresh = 0; 444 444 } 445 445 } 446 if (iters < 0) { 447 printf("Starting: infinite intervals of %d second%s each\n", 448 interval, 449 (interval == 1) ? "" : "s"); 450 } else { 446 if (iters >= 0) { 451 447 printf("Starting: %d interval%s of %d second%s each\n", iters, 452 448 (iters == 1) ? "" : "s", interval, 453 449 (interval == 1) ? "" : "s"); … … 456 452 signal(SIGWINCH, winch_handler); 457 453 458 454 then = system_time(); 455 if (iters < 0) { 456 // You will only have to wait half a second for the first iteration. 457 uinterval = 1 * 1000000 / 2; 458 baseline = gather(NULL, &busy, 0, refresh); 459 elapsed = system_time() - then; 460 if (elapsed < uinterval) { 461 snooze(uinterval - elapsed); 462 elapsed = uinterval; 463 } 464 then = system_time(); 465 baseline = gather(&baseline, &busy, elapsed, refresh); 466 } else 467 baseline = gather(NULL, &busy, 0, refresh); 468 459 469 uinterval = interval * 1000000; 460 baseline = gather(NULL, &busy, 0, refresh);461 470 for (i = 0; iters < 0 || i < iters; i++) { 462 471 elapsed = system_time() - then; 463 472 if (elapsed < uinterval) {