using System.Diagnostics;
private static long Benchmark(Action act, int iterations)
Stopwatch sw = Stopwatch.StartNew();
for (int i = 0; i < iterations; i++)
Console.WriteLine((sw.ElapsedTicks).ToString());
public static void Main(string[] args)
var empty = Benchmark(() => { }, 1000000);
var literal = Benchmark(() => { var x = 1E-3; }, 1000000);
var pow = Benchmark(() => { var x = Math.Pow(10, -3); }, 1000000);
Console.WriteLine("Variable assignment for numeric literal is {0} times faster then the same with Math.Pow", (double)(pow - empty) / (double)(literal - empty));