C#

C#,统计Function运行的时间

统计某个Function所运行的时间,在C#中可以使用Stopwatch ,Function:

try
{
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();

if (SqlDal.GetMaterialCount() > 0)
{
SqlDal.DeleteMaterial();
}
DataTable DT_Ora = OraDal.getDT_Ora();
string dtNum = SqlDal.CopyDate2Server(DT_Ora);
stopwatch.Stop();
string strLog = dtNum + “,运行时间:” + stopwatch.ElapsedMilliseconds + ” 毫秒”;
SqlDal.InsertLog(DateTime.Now.ToString(“yyyy-MM-dd HH:mm:ss”), strLog);
this.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}

Pls call me CPP.
Posts created 150

发表评论

Related Posts

Begin typing your search term above and press enter to search. Press ESC to cancel.

Back To Top