"Carl Daniel [VC++ MVP]" <
[email protected]>
wrote in message | | > Followup.
| > !!! Stopwatch.Elapsed.Ticks != Stopwatch.ElapsedTicks !!!
|
| A ha! I obviously hadn't looked at the code closely enough to realize
that
| it was using Elapsed.Ticks and not ElapsedTicks.
|
| > One should not use Elapsed.Ticks to calculate the elapsed time in
| > nanoseconds.
|
| True - one should use it to calculate the elapsed time in 0.1us units,
since
| that's what TimeSpan.Ticks is expressed as.
|
| > The only correct way to get this high precision count is by using
| > Stopwatch.ElapsedTicks like this:
| >
| > long nanosecPerTick = (1000L*1000L*1000L) / Stopwatch.Frequency;
|
| but make this a double. Stopwatch.Frequency is more than 1E9 on modern
| machines using the MP HAL.
|
| double nanosecPerTick = 1000.0 * 1000L * 1000L / Stopwatch.Frequency;
|
Sure, or use picoseconds
long picosecPerTick = 1000L * 1000L * 1000L * 1000L / Stopwatch.Frequency;
90614831400 picoseconds
Looks real crazy isn't it?
Willy.