diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2023-05-07 18:35:22 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2023-05-07 18:35:22 +0200 |
commit | c6058d221a44718d086e067b08b070bdce16a7ef (patch) | |
tree | 1b102c46f2b236a9a3da1ab191a0ed895f93fa4d | |
parent | 382e1634972f7aab883259dd22cf721d1c205055 (diff) | |
download | busybox-w32-c6058d221a44718d086e067b08b070bdce16a7ef.tar.gz busybox-w32-c6058d221a44718d086e067b08b070bdce16a7ef.tar.bz2 busybox-w32-c6058d221a44718d086e067b08b070bdce16a7ef.zip |
nmeter: improve %T fractionals display
function old new delta
nmeter_main 751 786 +35
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | procps/nmeter.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/procps/nmeter.c b/procps/nmeter.c index e52c868df..4197174ba 100644 --- a/procps/nmeter.c +++ b/procps/nmeter.c | |||
@@ -985,6 +985,15 @@ int nmeter_main(int argc UNUSED_PARAM, char **argv) | |||
985 | 985 | ||
986 | xgettimeofday(&G.start); | 986 | xgettimeofday(&G.start); |
987 | G.tv = G.start; | 987 | G.tv = G.start; |
988 | |||
989 | // Move back start of monotonic time a bit, to syncronize fractionals of %T and %t: | ||
990 | // nmeter -d500 '%6T %6t' | ||
991 | // 00:00:00.000161 12:32:07.500161 | ||
992 | // 00:00:00.500282 12:32:08.000282 | ||
993 | // 00:00:01.000286 12:32:08.500286 | ||
994 | if (G.delta > 0) | ||
995 | G.start.tv_usec -= (G.start.tv_usec % (unsigned)G.delta); | ||
996 | |||
988 | while (1) { | 997 | while (1) { |
989 | collect_info(first); | 998 | collect_info(first); |
990 | put_c(G.final_char); | 999 | put_c(G.final_char); |
@@ -999,6 +1008,15 @@ int nmeter_main(int argc UNUSED_PARAM, char **argv) | |||
999 | int rem; | 1008 | int rem; |
1000 | // can be commented out, will sacrifice sleep time precision a bit | 1009 | // can be commented out, will sacrifice sleep time precision a bit |
1001 | xgettimeofday(&G.tv); | 1010 | xgettimeofday(&G.tv); |
1011 | |||
1012 | // TODO: nmeter -d10000 '%6T %6t' | ||
1013 | // 00:00:00.770333 12:34:44.770333 | ||
1014 | // 00:00:06.000088 12:34:50.000088 | ||
1015 | // 00:00:16.000094 12:35:00.000094 | ||
1016 | // 00:00:26.000275 12:35:10.000275 | ||
1017 | // we can't syncronize interval to start close to 10 seconds for both | ||
1018 | // %T and %t (as shown above), but what if there is only %T | ||
1019 | // in format string? Maybe sync _it_ instead of %t in this case? | ||
1002 | if (need_seconds) | 1020 | if (need_seconds) |
1003 | rem = G.delta - ((ullong)G.tv.tv_sec*1000000 + G.tv.tv_usec) % G.deltanz; | 1021 | rem = G.delta - ((ullong)G.tv.tv_sec*1000000 + G.tv.tv_usec) % G.deltanz; |
1004 | else | 1022 | else |