public static long MeasureMethod(object context, MethodInfo method, object[] argumentArray) { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); method.Invoke(context, argumentArray); stopwatch.Stop(); return stopwatch.ElapsedMilliseconds; }