Subject | Hash | Author | Date (UTC) |
---|---|---|---|
ts: Introduce '-m' option to use CLOCK_MONOTONIC | 96809417fcceb13c83caa6b16d8174ea209bce27 | Ben Leinweber | 2017-10-30 15:24:47 |
Revert "ts: Introduce '-m' option to use CLOCK_MONOTONIC" | b6a010d759c53befdc9755760d28b6647d50f8b0 | Joey Hess | 2017-10-30 16:50:34 |
ts: Add -m option to use monotonic clock. Thanks, Ben Leinweber | 12845e32adcaa18b83cd8f3f01fddf9189c7ebda | Joey Hess | 2017-10-30 16:49:36 |
else indent style fix | 5b628493242860cdbec41a23e23bb561c96e4b40 | Joey Hess | 2017-10-30 16:49:12 |
ts: Introduce '-m' option to use CLOCK_MONOTONIC | d4592ac408f2086a3ed305c3fccf9107763e2be4 | Ben Leinweber | 2017-10-30 15:24:47 |
releasing package moreutils version 0.61 | 01d1b22f22fae647cbfd855dc82f8d9548607ab0 | Joey Hess | 2017-04-19 14:31:30 |
chronic: Flush output more often to better preserve stdout,err ordering. | 53c35a635276bb78f098947755dd072b5b800358 | Joey Hess | 2016-10-17 15:49:07 |
releasing package moreutils version 0.60 | 1173bd9f10d731485f3b63f1c7ff55eb9c58a605 | Joey Hess | 2016-08-13 13:58:21 |
Modify Cygwin check to use findstring instead of uname -o | 2d427c09cff6e7666e07c301c4b46c6206362a36 | Tony Kelman | 2016-08-10 03:23:52 |
changelog | e725f4d1607312a8ed3a5690e2926c26d5c48a61 | Joey Hess | 2016-07-19 01:03:36 |
include licence text | 29f0d5b620d63de94c066d50e4e468b51037c543 | Joey Hess | 2016-07-19 01:03:25 |
add dependency | e1a2473fff49f7caee1561bff38ee43ba5a97507 | Joey Hess | 2016-07-19 01:02:15 |
Merge is_utf8 from https://github.com/julienpalard/is_utf8. | 089fa36ad806246278b43df8dadb9a7882d39e54 | Julien Palard | 2016-07-18 22:48:55 |
changelog | ccf04c19111b1a2ccae7a16bb07a38a528a34a64 | Joey Hess | 2016-07-15 20:20:10 |
cygwin support | dee9b5042951795cd7abc415f1c4f4becc6363d3 | StalkR | 2016-07-15 08:48:35 |
releasing package moreutils version 0.59 | f891e8d7aafa336b89d0252e31bf52e1510de6b8 | Joey Hess | 2016-04-02 19:23:51 |
style cleanup | 411d6d3c6a8912c83cfc8a77747d4e68ed66cb4f | Joey Hess | 2016-04-02 19:22:55 |
stderr trigger and verbose mode | 5394ef715c4550a627bb2b212de55008f58302b1 | Tomas Mudrunka | 2016-03-31 15:01:35 |
changelog | 166ba94a0ead7e6cda383fe77ddfe2f682521e7d | Joey Hess | 2016-03-23 15:48:58 |
parallel: include signal.h to fix warning when building with clang | 181124dc64d3bb3eb5f6bbf8529a147d5e7db45b | Kevin Bullock | 2016-03-22 16:10:30 |
File | Lines added | Lines deleted |
---|---|---|
ts | 20 | 4 |
File ts changed (mode: 100755) (index 63baf18..7f6ff85) | |||
... | ... | $|=1; | |
56 | 56 | my $rel=0; | my $rel=0; |
57 | 57 | my $inc=0; | my $inc=0; |
58 | 58 | my $sincestart=0; | my $sincestart=0; |
59 | my $mono=0; | ||
59 | 60 | use Getopt::Long; | use Getopt::Long; |
60 | GetOptions("r" => \$rel, "i" => \$inc, "s" => \$sincestart) || die "usage: ts [-r] [-i | -s] [format]\n"; | ||
61 | GetOptions("r" => \$rel, "i" => \$inc, "s" => \$sincestart, "m" => \$mono) || die "usage: ts [-r] [-i | -s] [format]\n"; | ||
61 | 62 | ||
62 | 63 | if ($rel) { | if ($rel) { |
63 | 64 | eval q{ | eval q{ |
... | ... | $format=shift if @ARGV; | |
77 | 78 | ||
78 | 79 | # For subsecond resolution, Time::HiRes is needed. | # For subsecond resolution, Time::HiRes is needed. |
79 | 80 | my $hires=0; | my $hires=0; |
80 | if ($format=~/\%\.[Ss]/) { | ||
81 | if ($format=~/\%\.[Ss]/ || $mono) { | ||
81 | 82 | require Time::HiRes; | require Time::HiRes; |
83 | use Time::HiRes qw(CLOCK_MONOTONIC); | ||
82 | 84 | $hires=1; | $hires=1; |
83 | 85 | } | } |
84 | 86 | ||
85 | 87 | my $lastseconds = 0; | my $lastseconds = 0; |
86 | 88 | my $lastmicroseconds = 0; | my $lastmicroseconds = 0; |
87 | 89 | ||
88 | if ($hires) { | ||
90 | if ($mono) { | ||
91 | my $raw_time = Time::HiRes::clock_gettime(CLOCK_MONOTONIC); | ||
92 | $lastseconds = int($raw_time); | ||
93 | $lastmicroseconds = int(1000000 * ($raw_time - $lastseconds)); | ||
94 | } elsif ($hires) { | ||
89 | 95 | ($lastseconds, $lastmicroseconds) = Time::HiRes::gettimeofday(); | ($lastseconds, $lastmicroseconds) = Time::HiRes::gettimeofday(); |
90 | 96 | } else { | } else { |
91 | 97 | $lastseconds = time; | $lastseconds = time; |
... | ... | while (<>) { | |
96 | 102 | if (! $rel) { | if (! $rel) { |
97 | 103 | if ($hires) { | if ($hires) { |
98 | 104 | my $f=$format; | my $f=$format; |
99 | my ($seconds, $microseconds) = Time::HiRes::gettimeofday(); | ||
105 | my $seconds; | ||
106 | my $microseconds; | ||
107 | if ($mono) { | ||
108 | my $raw_time = | ||
109 | Time::HiRes::clock_gettime(CLOCK_MONOTONIC); | ||
110 | $seconds = int($raw_time); | ||
111 | $microseconds = int(1000000 * ($raw_time - $seconds)); | ||
112 | } else { | ||
113 | ($seconds, $microseconds) = Time::HiRes::gettimeofday(); | ||
114 | } | ||
115 | |||
100 | 116 | if ($inc || $sincestart) { | if ($inc || $sincestart) { |
101 | 117 | my $deltaseconds = $seconds - $lastseconds; | my $deltaseconds = $seconds - $lastseconds; |
102 | 118 | my $deltamicroseconds = $microseconds - $lastmicroseconds; | my $deltamicroseconds = $microseconds - $lastmicroseconds; |