Imports System.Diagnostics
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles Button1.Click
'初期化と同時にカウント開始
Dim stpw As Stopwatch = Stopwatch.StartNew
'Dim stpw As Stopwatch = New Stopwatch
''カウント開始
'stpw.Start()
''----------------------------------------
''時間計測したい処理 ここから
''----------------------------------------
Dim strTest As String = ""
For i As Integer = 1 To 5000
strTest += "TEST"
Next
''----------------------------------------
''時間計測したい処理 ここまで
''----------------------------------------
''カウント停止
stpw.Stop()
Console.WriteLine("処理は {0} ミリ秒かかりました。", stpw.ElapsedMilliseconds)
End Sub
End Class
|