瞭解程式執行時間
轉貼文章:http://tfeng.org/?p=1215 逐風者 這是 .net framework 2.0 新增的類別,可以讓你知道您得程式耗費多少時間,有助於優化自己得程式! ? View Code VB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 VB.net Code: Dim sw As New System.Diagnostics.Stopwatch() Dim num As Long = 0 sw.Reset() sw = Stopwatch.StartNew() '要測速的程式碼放這裡 sw. Stop () Dim ms As Long = sw.ElapsedMilliseconds Debug. Print ( "花費 {0} 毫秒" , ms) Dim el As TimeSpan = sw.Elapsed Debug. Print ( "花費 {0} " , el) 範例:(檢查 do ...... loop 花的時間) Dim sw As New System.Diagnostics.Stopwatch() Dim num As Long = 0 sw.Reset() sw = Stopwatch.StartNew() Do unitle x>100 x += 1 loop sw. Stop () Dim ms As Long = sw.ElapsedMilliseconds Debug. Print ( "花費 {0} 毫秒" , ms) Dim el As TimeSpan = sw.Elapsed Debug. Print ( "花費 {0} " , el) C# Code: ? View Code CSHAPE 1 2 3 4 5 6 7 8 9 10 11 12 using System.Diagnostics; //------------------------------------------- Stopwatch sw = new Stopwat...