diff options
author | Dima Kogan <dima@secretsauce.net> | 2018-12-27 23:17:08 -0800 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2018-12-31 11:49:59 -0400 |
commit | 5a199f3531a594508679b1b758b794504b44d362 (patch) | |
tree | ee1fe7771a90d6376305361665959bd52734fe71 | |
parent | 01f1a21ebdea10347fdae5dcc3b184182409255e (diff) | |
download | moreutils-5a199f3531a594508679b1b758b794504b44d362.tar.gz |
ts -m now works even with hires formats
I.e. 'ts -m %.s' now does reasonable things. There was a bug in the handling of
the offset between the normal and hi-res clocks
-rwxr-xr-x | ts | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -100,7 +100,7 @@ if ($mono) { my $raw_time = Time::HiRes::clock_gettime(CLOCK_MONOTONIC); $lastseconds = time; $lastmicroseconds = int(1000000 * ($raw_time - int($raw_time))); - $monodelta = time - int($raw_time); + $monodelta = $lastseconds - int($raw_time); } elsif ($hires) { ($lastseconds, $lastmicroseconds) = Time::HiRes::gettimeofday(); @@ -118,8 +118,9 @@ while (<>) { my $microseconds; if ($mono) { my $raw_time = - Time::HiRes::clock_gettime(CLOCK_MONOTONIC); - $seconds = $monodelta + int($raw_time); + Time::HiRes::clock_gettime(CLOCK_MONOTONIC) + + $monodelta; + $seconds = int($raw_time); $microseconds = int(1000000 * ($raw_time - $seconds)); } else { |