Why this matters
DateTime.Now is affected by daylight savings and system clock adjustments. Use Stopwatch for more accurate timing.
DateTime.Now for Timing OperationsDateTime.Now is affected by daylight savings and system clock adjustments. Use Stopwatch for more accurate timing.
DateTime.Now is affected by daylight savings and system clock adjustments. Use Stopwatch for more accurate timing.
Side-by-side examples engineers can pattern-match during review.
var start = DateTime.Now; // First call, on March 26th 2:59 am
MethodToBeBenchmarked();
Console.WriteLine($"{(DateTime.Now - start).TotalMilliseconds} ms"); // Second call happens 2 minutes later but `Now` is March 26th, 4:01 am as there's a shift to summer timevar stopWatch = Stopwatch.StartNew(); // Compliant
MethodToBeBenchmarked();
stopWatch.Stop();
Console.WriteLine($"{stopWatch.ElapsedMilliseconds} ms");From the same buckets as this rule.
All static JS/CSS/font/image files MUST use content-hashed filenames (e.g., app.9c1a7b.js) and be served with "Cache-Control: public, max-age=31536000, immutable". HTML and other non-fingerprinted documents MUST be served with "Cache-Control: no-cache" (or equivalent) to enable conditional revalidation.