4 ms·
That may not even be the biggest flaw; using DateTime.Now as the timing mechanism for small benchmarks is pretty inaccurate because the resolution is rather poo
by profquail 14y ago
That may not even be the biggest flaw; using DateTime.Now as the timing mechanism for small benchmarks is pretty inaccurate because the resolution is rather poor.
The recommended way is to use System.Diagnostics.Stopwatch, since that uses the CPU's built-in high-performance timer (HPET).
- ajanuary 14y agoIt also doesn't do any warm-up (run the code a few times untimed) which puts the JITer at a disadvantage.