ofp-print: Print durations with at least three decimals.
authorBen Pfaff <blp@nicira.com>
Fri, 20 Dec 2013 16:39:27 +0000 (08:39 -0800)
committerBen Pfaff <blp@nicira.com>
Fri, 20 Dec 2013 16:40:43 +0000 (08:40 -0800)
commitb1634591bc7103fa511c8a6a920b370641da3b0e
tree445b4ecb00831adfb71361a5945eb4c3ef947866
parent83916319a914a4111cabf52a115368ebf5320123
ofp-print: Print durations with at least three decimals.

Occasionally I run a command like this:
    watch -n.1 ovs-ofctl dump-flows br0
to see how flows change over time.  Until now, it has been more difficult
than necessary to spot real changes, because flows "jump around" as the
number of decimals printed for duration changes from moment to moment.
That is, you might see
    cookie=0x0, duration=4.566s, table=0, n_packets=0, ...
one moment, and then
    cookie=0x0, duration=4.8s, table=0, n_packets=0, ...
the next moment.  Shortening 4.8 to 4.800 shifts everything following it
two places to the left, creating a visual jump.

This commit avoids that problem by always printing at least three decimals
if we print any.  There can still be an occasional jump if a duration is
exactly on a second boundary, but that only happens 1/1000 of the time.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>
lib/ofp-print.c
tests/ofp-print.at