|
Sub Doint()
Const myMAX As Integer = 32767
Const myMIN As Integer = -32767
Dim i As Integer, t As Date
Dim 加法%, 减法%, 乘法%, 除法%, 求余%
Dim cnt As Integer
'循环100次
t = Timer
For cnt = 1 To 1000
For i = myMIN To myMAX - 1
加法 = i + 1
减法 = i - 1
乘法 = i * 1
除法 = i / 1
求余 = i Mod 1
Next i
Next cnt
MsgBox Format(Timer - t, "0.00")
End Sub
Sub Dolong()
Const myMAX As Long = 32767#
Const myMIN As Long = -32767#
Dim l As Long, t As Date
Dim 加法#, 减法#, 乘法#, 除法#, 求余#, cnt As Long
'循环100次
t = Timer
For cnt = 1 To 1000
For l = myMIN To myMAX - 1
加法 = l + 1
减法 = l - 1
乘法 = l * 1
除法 = l / 1
求余 = l Mod 1
Next l
Next cnt
MsgBox Format(Timer - t, "0.00")
End Sub
为什么我的机器int 4秒多,long 6秒呢? 1000次 |
|