public class StopWatch { static public int AN_HOUR = 60 * 60 * 1000; static public int A_MINUTE = 60 * 1000; ;PRivate long startTime = -1; private long stopTime = -1; /** ;* 启动秒表 */ public void start() { this.startTime =System.currentTimeMillis(); }…
最近程序上用到了计时功能,对某个模块进行计时,暂停的时候模块也需要暂停,启动的时候计时继续 用到了Stopwatch Stopwatch的命名空间是using System.Diagnostics; using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Text; using System.Threading; using System.T…
我们可以用Stopwatch类获得程序的运行时间,在优化代码时,可以用此方法来查看优化前后程序所耗费的时间 //Stopwatch类別在System.Diagnostics命名空间里 Stopwatch sw = new Stopwatch(); long num = 0;sw.Reset(); sw = Stopwatch.StartNew();for (int i = 1; i < 100000000; i++){ num += 1;}sw.Stop();TimeSpan el = sw.E…