C#程序代码耗时统计

C# 1101次浏览 本站
using System.Diagnostics;

Stopwatch sw = new Stopwatch();
sw.Start();
 
List<NoteInfo> notelist = Note.GetAllNotes();
dgvNoteList.DataSource = notelist;
 
sw.Stop();
TimeSpan ts = sw.Elapsed;
string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10);
LblTimeSpan.Text = "耗时:" elapsedTime " 共计:" notelist.Count "条记录";
 

发表评论

电子邮件地址不会被公开。 必填项已用*标注