From 2f93b89b62d10fa75a6869a4f84cad861c0aea1b Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sat, 21 Oct 2023 05:30:26 -0500 Subject: [PATCH] Fix rate calculation. --- toys/other/count.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/toys/other/count.c b/toys/other/count.c index 41fbb375..58b25bb0 100644 --- a/toys/other/count.c +++ b/toys/other/count.c @@ -26,14 +26,24 @@ GLOBALS( static void display(unsigned long long now) { unsigned long long bb; - unsigned seconds, ii, len = TT.tick ? : 1; + unsigned seconds, ii, len = TT.tick ? minof(TT.tick, 63): 1; - // raw number, human readable, time, and recent/total rate + // bytes, human readable size, elapsed time, rate over last 16 seconds if (FLAG(l)) { human_readable(toybuf+256, TT.size, 0); seconds = (now - TT.start)/1000; - for (bb = ii = 0, len = minof(len, 64); iiTT.start && len>now-TT.start) len = now-TT.start; + human_readable(toybuf+512, (bb*1000)/len, 0); + sprintf(toybuf+1024, ", %sb, %sb/s, %um%02us", toybuf+256, toybuf+512, seconds/60, seconds%60); } -- 2.39.2