// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Diagnostics; using System.Reflection; namespace E { public class MainClass { private const int N = 100000; public static void Main(string[] args) { Console.WriteLine(MethodInfo.GetCurrentMethod().Name); DateTime t1 = DateTime.Now; for(int i = 0; i < N; i++) { string nam = MethodInfo.GetCurrentMethod().Name; } DateTime t2 = DateTime.Now; Console.WriteLine((t2 - t1).TotalSeconds); Console.WriteLine((new StackTrace(true)).GetFrame(0).GetMethod().Name); DateTime t3 = DateTime.Now; for(int i = 0; i < N; i++) { string nam = (new StackTrace(true)).GetFrame(0).GetMethod().Name; } DateTime t4 = DateTime.Now; Console.WriteLine((t4 - t3).TotalSeconds); } } }