summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDima Kogan <dima@secretsauce.net>2018-12-27 23:17:08 -0800
committerJoey Hess <joeyh@joeyh.name>2018-12-31 11:49:59 -0400
commit5a199f3531a594508679b1b758b794504b44d362 (patch)
treeee1fe7771a90d6376305361665959bd52734fe71
parent01f1a21ebdea10347fdae5dcc3b184182409255e (diff)
downloadmoreutils-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-xts7
1 files changed, 4 insertions, 3 deletions
diff --git a/ts b/ts
index 8a2b8bb..1b9f0a7 100755
--- a/ts
+++ b/ts
@@ -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 {