What does ElapsedTicks
and Elapsed.Ticks
in the StopWatch class mean? When could the meaning be different than intended?
是什么东西在流逝。秒表班的滴答声是什么意思?什么时候意义会与预期不同?
2 个解决方案
#1
21
I just found out that ElapsedTicks in the StopWatch class doesn't mean real "ticks" if StopWatch.isHighResolution is True
我刚发现秒表上的秒表不代表秒表的“滴答”。isHighResolution是真的
Note(if isHighResolution is True):
备注(如果isHighResolution是真的):
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.
秒表蜱与日期时间不同。在日期时间内的每一个滴答。节拍值表示一个100纳秒的间隔。ElapsedTicks值中的每个滴答数表示时间间隔为1秒,除以频率。
You can do the math above or it seem you can use StopWatch.Elapsed.Ticks instead of StopWatch.ElapsedTicks
你可以做上面的计算,或者你可以用秒表。蜱虫而不是StopWatch.ElapsedTicks
#2
11
Elapsed.Ticks / TimeSpan.TicksPerSecond == ElapsedTicks / Stopwatch.Frequency
Of course this may not exactly equal due to rounding, as Stopwatch ticks and TimeSpan ticks are measured in different units. Also, in case you executed the above code literally, obviously some ticks would elapse between taking the value of Elapsed.Ticks
and that of ElapsedTicks
.
当然,由于四舍五入的原因,这可能并不完全相等,因为秒表的节拍和TimeSpan节拍是用不同的单位测量的。同样,如果您逐字执行上面的代码,很明显,在使用经过的值之间会出现一些节拍。蜱和毒蛇的。
#1
21
I just found out that ElapsedTicks in the StopWatch class doesn't mean real "ticks" if StopWatch.isHighResolution is True
我刚发现秒表上的秒表不代表秒表的“滴答”。isHighResolution是真的
Note(if isHighResolution is True):
备注(如果isHighResolution是真的):
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.
秒表蜱与日期时间不同。在日期时间内的每一个滴答。节拍值表示一个100纳秒的间隔。ElapsedTicks值中的每个滴答数表示时间间隔为1秒,除以频率。
You can do the math above or it seem you can use StopWatch.Elapsed.Ticks instead of StopWatch.ElapsedTicks
你可以做上面的计算,或者你可以用秒表。蜱虫而不是StopWatch.ElapsedTicks
#2
11
Elapsed.Ticks / TimeSpan.TicksPerSecond == ElapsedTicks / Stopwatch.Frequency
Of course this may not exactly equal due to rounding, as Stopwatch ticks and TimeSpan ticks are measured in different units. Also, in case you executed the above code literally, obviously some ticks would elapse between taking the value of Elapsed.Ticks
and that of ElapsedTicks
.
当然,由于四舍五入的原因,这可能并不完全相等,因为秒表的节拍和TimeSpan节拍是用不同的单位测量的。同样,如果您逐字执行上面的代码,很明显,在使用经过的值之间会出现一些节拍。蜱和毒蛇的。