2019年8月16日 星期五

計算程式執行時間

------------------------------------------------------------------
方法 1
------------------------------------------------------------------
'測量己耗用的時間
Dim wt As New Stopwatch

wt.Start()
'程式內容
wt.Stop()
Dim i As Integer = wt.ElapsedMilliseconds / 1000
wt.Reset() 

------------------------------------------------------------------
方法 2
------------------------------------------------------------------
Dim ts As DateTime = DateTime.Now


' do someting....

Dim te As DateTime = DateTime.Now
MessageBox.Show( te.Subtract(ts).TotalSeconds & "sec")
------------------------------------------------------------------

沒有留言:

張貼留言