Subject | Hash | Author | Date (UTC) |
---|---|---|---|
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 |
allow specifying alternate path to docbook-xsl stylesheets | 6d8329a424db3f8f3251a58fe581c94f33aa0fd6 | Kevin Bullock | 2016-03-22 16:10:29 |
File | Lines added | Lines deleted |
---|---|---|
ts | 6 | 23 |
File ts changed (mode: 100755) (index 7134ea7..63baf18) | |||
... | ... | $|=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; | ||
60 | 59 | use Getopt::Long; | use Getopt::Long; |
61 | GetOptions("r" => \$rel, "i" => \$inc, "s" => \$sincestart, "m" => \$mono) || die "usage: ts [-r] [-i | -s] [format]\n"; | ||
60 | GetOptions("r" => \$rel, "i" => \$inc, "s" => \$sincestart) || die "usage: ts [-r] [-i | -s] [format]\n"; | ||
62 | 61 | ||
63 | 62 | if ($rel) { | if ($rel) { |
64 | 63 | eval q{ | eval q{ |
... | ... | $format=shift if @ARGV; | |
78 | 77 | ||
79 | 78 | # For subsecond resolution, Time::HiRes is needed. | # For subsecond resolution, Time::HiRes is needed. |
80 | 79 | my $hires=0; | my $hires=0; |
81 | if ($format=~/\%\.[Ss]/ || $mono) { | ||
80 | if ($format=~/\%\.[Ss]/) { | ||
82 | 81 | require Time::HiRes; | require Time::HiRes; |
83 | use Time::HiRes qw(CLOCK_MONOTONIC); | ||
84 | 82 | $hires=1; | $hires=1; |
85 | 83 | } | } |
86 | 84 | ||
87 | 85 | my $lastseconds = 0; | my $lastseconds = 0; |
88 | 86 | my $lastmicroseconds = 0; | my $lastmicroseconds = 0; |
89 | 87 | ||
90 | if ($mono) { | ||
91 | ($lastseconds, $lastmicroseconds) = | ||
92 | Time::HiRes::clock_gettime(CLOCK_MONOTONIC); | ||
93 | } elsif ($hires) { | ||
88 | if ($hires) { | ||
94 | 89 | ($lastseconds, $lastmicroseconds) = Time::HiRes::gettimeofday(); | ($lastseconds, $lastmicroseconds) = Time::HiRes::gettimeofday(); |
95 | } | ||
96 | else { | ||
90 | } else { | ||
97 | 91 | $lastseconds = time; | $lastseconds = time; |
98 | 92 | } | } |
99 | 93 | ||
... | ... | while (<>) { | |
102 | 96 | if (! $rel) { | if (! $rel) { |
103 | 97 | if ($hires) { | if ($hires) { |
104 | 98 | my $f=$format; | my $f=$format; |
105 | my ($seconds, $microseconds); | ||
106 | if ($mono) { | ||
107 | my $raw_time = | ||
108 | Time::HiRes::clock_gettime(CLOCK_MONOTONIC); | ||
109 | $seconds = int($raw_time); | ||
110 | $microseconds = $raw_time - $seconds; | ||
111 | print "$raw_time $seconds $microseconds\n"; | ||
112 | } | ||
113 | else { | ||
114 | ($seconds, $microseconds) = Time::HiRes::gettimeofday(); | ||
115 | } | ||
99 | my ($seconds, $microseconds) = Time::HiRes::gettimeofday(); | ||
116 | 100 | if ($inc || $sincestart) { | if ($inc || $sincestart) { |
117 | 101 | my $deltaseconds = $seconds - $lastseconds; | my $deltaseconds = $seconds - $lastseconds; |
118 | 102 | my $deltamicroseconds = $microseconds - $lastmicroseconds; | my $deltamicroseconds = $microseconds - $lastmicroseconds; |
... | ... | while (<>) { | |
139 | 123 | $lastseconds = $seconds; | $lastseconds = $seconds; |
140 | 124 | } | } |
141 | 125 | print strftime($format, localtime($deltaseconds)); | print strftime($format, localtime($deltaseconds)); |
142 | } | ||
143 | else { | ||
126 | } else { | ||
144 | 127 | print strftime($format, localtime); | print strftime($format, localtime); |
145 | 128 | } | } |
146 | 129 | } | } |