4

タイマーの精度と分解能の意味がわかりません。誰かが私にそれを説明できますか?

注: この質問はストップウォッチに関連しています。

4

4 に答える 4

6

Accuracy and precision are opposing goals, you can't get both. An example of a very accurate timing source is DateTime.UtcNow. It provides absolute time that's automatically corrected for clock rate errors by the kernel, using a timing service to periodically re-calibrate the clock. You probably heard of time.windows.com, the NTP server that most Windows PC use. Very accurate, you can count on less than a second of error over an entire year. But not precise, the value only updates 64 times per second. It is useless to time anything that takes less than a second with any kind of decent precision.

The clock source for Stopwatch is very different. It uses a free running counter that is driven by a frequency source available somewhere in the chipset. This used to be a dedicate crystal running at the color burst frequency (3.579545 MHz) but relentless cost cutting has eliminated that from most PCs. Stopwatch is very precise, you can tell from its Frequency property. You should get something between a megahertz and the cpu clock frequency, allowing you to time down to a microsecond or better. But it is not accurate, it is subject to electronic part tolerances. Particularly mistrust any Frequency beyond a gigahertz, that's derived from a multiplier which also multiplies the error. And beware the Heisenberg principle, starting and stopping the Stopwatch takes non-zero overhead that will affect the accuracy of very short measurements. Another common accuracy problem with Stopwatch is the operating system switching out your thread to allow other code to run. You need to take multiple samples and use the median value.

于 2012-05-27T14:30:09.147 に答える
0

それらは、他の測定と同じです。詳細については、このウィキペディアの記事を参照してください --

http://en.wikipedia.org/wiki/Accuracy_and_precision

于 2012-05-27T12:55:22.787 に答える
0

.net にはさまざまなタイプの時間 (私の記憶が正しければ 3 つまたは 4 つ) があり、それぞれ独自のアルゴリズムで動作します。タイマーの精度とは、使用しているアプリケーションにティック イベントを通知する際の正確さを意味します。たとえば、タイマーを使用して 1000 ミリ秒ごとに刻みイベントをトリガーするように設定した場合、タイマーの精度は、指定された 1000 ミリ秒に実際にどれだけ刻むかを意味します。
詳細については(少なくともC#で)、タイマーに関するmsdnページを読むことをお勧めします:

于 2012-05-27T12:55:53.623 に答える
0

MSDNストップウォッチクラスから:(強調鉱山)

「Stopwatch は、基礎となるタイマー メカニズムのタイマー ティックをカウントすることによって経過時間を測定します。インストールされているハードウェアとオペレーティング システムが高解像度のパフォーマンス カウンターをサポートしている場合、Stopwatch クラスはそのカウンターを使用して経過時間を測定します。それ以外の場合、Stopwatch クラスは経過時間を測定するためのシステム タイマー。Frequency フィールドと IsHighResolution フィールドを使用して、ストップウォッチタイミングの実装の精度と解像度を決定します。"

于 2012-05-27T14:43:07.897 に答える