使用Diagnostics.Stopwatch,获取当前实例测量得出的运行时间,以毫秒为单位,直接上代码:
Dim watch As New Diagnostics.Stopwatch
Dim a As Double
Dim b As Double
/*创建该全宗的第一级类别*/
watch.Start()
/*优化前代码体*/
CreateNode1()
watch.Stop()
a = watch.Elapsed.TotalMilliseconds
watch.Start()
/*优化后代码体*/
CreateNode2()
watch.Stop()
b = watch.Elapsed.TotalMilliseconds
demo.WriteLog("优化前:" & a.ToString & ";优化后:" & (b - a).ToString & ";提速百分比:" & (2 - b / a).ToString & vbCrLf)