/// <summary> /// 计时。 /// </summary> /// <param name="times">次数。</param> /// <param name="action">测试项。</param> /// <returns></returns> public static CodeTimer Time(Int32 times, Action <Int32> action) { CodeTimer timer = new CodeTimer(); timer.Times = times; timer.Action = action; timer.TimeOne(); timer.Time(); return(timer); }
/// <summary> /// 计时,并用控制台输出行 /// </summary> /// <param name="title">标题。</param> /// <param name="times">次数。</param> /// <param name="action">测试项。</param> public static void TimeLine(String title, Int32 times, Action <Int32> action) { Console.Write("{0,16}:", title); CodeTimer timer = new CodeTimer(); timer.Times = times; timer.Action = action; timer.ShowProgress = true; ConsoleColor currentForeColor = Console.ForegroundColor; Console.ForegroundColor = ConsoleColor.Yellow; timer.TimeOne(); timer.Time(); Console.WriteLine(timer.ToString()); Console.ForegroundColor = currentForeColor; }
/// <summary> /// 计时。 /// </summary> /// <param name="times">次数。</param> /// <param name="action">测试项。</param> /// <returns></returns> public static CodeTimer Time(Int32 times, Action<Int32> action) { CodeTimer timer = new CodeTimer(); timer.Times = times; timer.Action = action; timer.TimeOne(); timer.Time(); return timer; }
/// <summary> /// 计时,并用控制台输出行 /// </summary> /// <param name="title">标题。</param> /// <param name="times">次数。</param> /// <param name="action">测试项。</param> public static void TimeLine(String title, Int32 times, Action<Int32> action) { Console.Write("{0,16}:", title); CodeTimer timer = new CodeTimer(); timer.Times = times; timer.Action = action; timer.ShowProgress = true; ConsoleColor currentForeColor = Console.ForegroundColor; Console.ForegroundColor = ConsoleColor.Yellow; timer.TimeOne(); timer.Time(); Console.WriteLine(timer.ToString()); Console.ForegroundColor = currentForeColor; }