獲取C#代碼執行的時間(精確到毫秒)

using System.Diagnostics;//引用相關的命名空間
Stopwatch st=new Stopwatch ();//實例化類
st. Start();//開始計時

//須要統計時間的代碼段

st.Stop();//終止計時
Response.Write(st.ElapsedMilliseconds.ToString());//輸出時間。輸出運行時間:Elapsed,帶毫秒的時間:ElapsedMilliseconds
//Response.Write是asp .net中使用的輸出
相關文章
相關標籤/搜索