|
|
发表于 2005-11-21 22:11:00
|
显示全部楼层
Re: 对VB的效率不满意?原因可能出在你自己身上哦!
哇哈哈哈哈!!!!
esxgx
我就来给你叫板哦~
我的vb.net优化后30MS!!
比你的就慢那么一丁点哦~
同样的代码给vb用没什么太大效果~
不过vb.net就是不一样~
下面是优化后原码:
Private Declare Function GetTickCount Lib "kernel32" Alias "GetTickCount" () As Integer
Sub Main()
Dim st As Integer = GetTickCount
Dim i As Integer = 100000000, d As Integer = 0, d1 As Integer = 10
If i Mod 10 = 0 Then
Do While i > 0
i = i - 10
d = d + 10
Loop
ElseIf i Mod 4 = 0 Then
Do While i > 0
i = i - 4
d = d + 4
Loop
ElseIf i Mod 2 = 0 Then
Do While i > 0
i = i - 2
d = d + 2
Loop
ElseIf i Mod 1 = 0 Then
Do While i > 0
i = i - 1
d = d + 1
Loop
End If
i = i + 1
d = d + 1
Console.WriteLine("d的结果(第一次):" & d & vbCrLf)
i = 0
d = 10
Do While i < 5
i = i + 1
d1 = (d1 << 3) + (d1 << 1)
Loop
Console.WriteLine("d的结果(第二次):" & d1 & vbCrLf)
Console.WriteLine("一共执行时间:" & GetTickCount - st & "毫秒" & vbCrLf)
下面幅上截图,上面是优化前,下面是优化后 |
|