public static TimeSpan time <T>(Action <T> a, T p, string desc) { HighPerfTimer hpt = new HighPerfTimer(); hpt.start(); a(p); hpt.stop(); TimeSpan ts = new TimeSpan(hpt.gs_ticks); string time = DateTime.Now.ToShortTimeString(); addField(ref time, desc); addField(ref time, ts.TotalMilliseconds.ToString()); trace(time); return(ts); }
public static T timeFunc <T, P1, P2>(Func <P1, P2, T> a, P1 p1, P2 p2, string desc) { HighPerfTimer hpt = new HighPerfTimer(); hpt.start(); T toRet = a(p1, p2); hpt.stop(); TimeSpan ts = new TimeSpan(hpt.gs_ticks); string time = DateTime.Now.ToShortTimeString(); addField(ref time, desc); addField(ref time, ts.TotalMilliseconds.ToString()); trace(time); return(toRet); }