统计某个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());
}