11 lines
707 B
Plaintext
11 lines
707 B
Plaintext
== How to fix it
|
|
|
|
=== Code examples
|
|
|
|
If the purpose is to benchmark something then, instead of the `DateTime.Now` property, it's recommended to use `Stopwatch`, which is not affected by changes in time such as daylight savings (DST) and automatically checks for the existence of high-precision timers. As a bonus, the `StopWatch` class is also lightweight and computationally faster than `DateTime`.
|
|
|
|
include::{language}/non-compliant-example-benchmark.adoc[]
|
|
|
|
If, on the other hand, the goal is to refresh a timer prefer using the `DateTime.UtcNow` property, which guarantees reliable results when doing arithmetic operations during DST transitions.
|
|
|
|
include::{language}/non-compliant-example-timing.adoc[] |