Usually a timer is not used for this - you are using Stopwatch .
Stopwatch sw = Stopwatch.StartNew(); // Do work sw.Stop(); TimeSpan elapsedTime = sw.Elapsed;
If you benchmark something relatively quickly, you should do it many, many times so that the time is significant (I usually go for 5-30 seconds). This is not always feasible, admittedly, and there are many more subtleties that affect real-world performance (like cache hits / skips) that often skip micro-benchmarking.
In principle, be careful, but Stopwatch is probably the best starting point in many cases.
Jon skeet
source share