時間測定精度に関連するLinuxパッチ?

時間測定精度に関連するLinuxパッチ?

(ユーザー以外のシステム)プロセス時間精度を扱うLinuxカーネル用のパッチセットはありますか?

RTLinuxについて聞いたことがありますが、実際には実際のリアルタイムスケジューリング制約は必要なく、正確な時間測定のみが必要です。プロセススイッチが数ミリ秒間スライドすることは可能ですが、現在のプロセスにかかる実際の時間を正確に測定する必要があります。

ベストアンサー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内蔵型なのでオーバーヘッドが少ないです。したがって、3桁の制限があるのには理由があります。残りはランダムなごみです。

また、見ることができますこの同様の質問、現在許可されている答えには小さなバグが含まれています。

おすすめ記事