патчи Linux связаны с точностью измерения времени?

Это должно быть:

ls | xargs -n 1 command -r

Править: для имен с пробелами:

ls | xargs -d '\n' -n 1 command -r
5
01.09.2011, 16:09
1 ответ

Если то, что Вы имеете в виду, является использованием time встроенная оболочка, затем 3 точности цифры является ограничением дизайна - согласно man bash:

TIMEFORMAT
          The value of this parameter is used as a format string  specify‐
          ing  how  the timing information for pipelines prefixed with the
          time reserved word should be displayed.  The % character  intro‐
          duces  an  escape  sequence  that is expanded to a time value or
          other information.  The escape sequences and their meanings  are
          as follows; the braces denote optional portions.
          %%        A literal %.
          %[p][l]R  The elapsed time in seconds.
          %[p][l]U  The number of CPU seconds spent in user mode.
          %[p][l]S  The number of CPU seconds spent in system mode.
          %P        The CPU percentage, computed as (%U + %S) / %R.

          The  optional  p is a digit specifying the precision, the number
          of fractional digits after a decimal point.  A value of 0 causes
          no decimal point or fraction to be output.  At most three places
          after the decimal point may be specified; values  of  p  greater
          than  3 are changed to 3.  If p is not specified, the value 3 is
          used.

Для по-видимому более точных измерений можно попытаться использовать date со специализированным выходным форматированием для показа наносекунд:

Tstart=$(date "+%s.%N")
some_command(s)
Tend=$(date "+%s.%N")
echo "Elapsed: $( Tend-Tstart |bc -l) nanoseconds"

Однако заметьте это в обоих случаях (time и date), у Вас есть немного служебные, поскольку система занимает время для выполнения запускающих/останавливающих команд. Издержки меньше для time, благодаря ему являющийся встроенным. Таким образом, трехразрядный предел там по причине: остальное - просто случайный мусор.

См. также этот подобный вопрос, хотя принятый ответ в настоящее время содержит немного ошибки.

2
27.01.2020, 20:42

Теги

Похожие вопросы