04 2012 档案

摘要:/* var obj = document.getElementById("times"); var ms = 0; var state = 0; function startstop() { if (state == 0) { state = 1; then = new Date(); then.setTime(then.getTime() - ms); } else { state = 0; now = new Date(); ms = now.getTime() - then.getTime(); obj.innerHTML = ms/1000; } } functi 阅读全文
posted @ 2012-04-18 09:45 itecho 阅读(197) 评论(0) 推荐(0)
摘要:(1)用Datatime和TmeSpan这个不说了,在要测量的代码前后加上2个DateTime.Now,2者相减,得到一个TmeSpan。DateTime d = DateTime.Now;for (int i = 0; i < 1000; i++){++i;}Console.WriteLine(DateTime.Now - d);(2)用Stopwatch,简单,明了,精确。// 使用 StopWatch 进行测量Stopwatch sw = new Stopwatch();sw.Start();for (int i = 0; i < 1000; i++) { ++i; }sw. 阅读全文
posted @ 2012-04-06 13:45 itecho 阅读(545) 评论(0) 推荐(0)