How can I find out how much time my C# code takes to run?
The Stopwatch class offers high-precision timing in .NET. It is capable of measuring time with sensitivity of around 100s of nanoseconds (fractions of milliseconds). To get the exact resolution, read the value of Stopwatch.Frequency.
var timer = System.Diagnostics.Stopwatch.StartNew();
// Run code here.
var elapsed = timer.ElapsedMilliseconds.
Also, be sure to run your code repeatedly (as many times as is feasible) to get a better average time, as well as to reduce the effects of fluctuations in CPU load.