Differences in Elapsed Ticks property of Stopwatch
Asked Answered
F

1

10

ElapsedTicks & Elapsed.Ticks are properties of Stopwatch, which I think should be same. And in case they are same, why they should give different outputs ?

Code :

Stopwatch spwt = Stopwatch.StartNew();
spwt.Stop();
Console.WriteLine(spwt.ElapsedTicks);
Console.WriteLine(spwt.Elapsed.Ticks);

Output :

6
16

Why is this difference observed ? shouldn't it be same ?

Fissure answered 15/9, 2011 at 14:42 Comment(1)
Does this answer your question? Are StopWatch.ElapsedTicks and StopWatch.Elapsed.Ticks always the same?Metronymic
S
14

See https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.stopwatch.elapsedticks#remarks :

Note

Stopwatch ticks are different from DateTime.Ticks. Each tick in the DateTime.Ticks value represents one 100-nanosecond interval. Each tick in the ElapsedTicks value represents the time interval equal to 1 second divided by the Frequency.

Shontashoo answered 15/9, 2011 at 14:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.