回复 15# happytc
怎么我测的FOR 比 DO 还快呢?帮忙看代码,看下那里错了,如下:
#include <Array.au3>
Dim $sArray[5][2]=[["For...To...Step...Next "],["For...To...Next "],["For...In...Next "],["While...WEnd"],["Do...Until"]] ;数组初始化
Local $a = 0 ,$list =0 ,$i = 0, $j = 0
Local $begin = TimerInit()
For $i = 1 To 100 Step 1
For $j = 1 To 10000 Step 1
_add($a)
Next
Next
_list()
$begin = TimerInit()
For $i = 1 To 100
For $j = 1 To 10000
_add($a)
Next
Next
_list()
Local $ii[100], $jj[10000]
$begin = TimerInit()
For $i In $ii
For $j In $jj
_add($a)
$j += 1
Next
$i += 1
$j = 0
Next
_list()
$begin = TimerInit()
Local $i = 0, $j = 0
While $i <= 100
While $j <= 10000
_add($a)
$j += 1
WEnd
$i += 1
$j = 0
WEnd
_list()
Local $i = 0, $j = 0
$begin = TimerInit()
Do
Do
_add($a)
$j += 1
Until $j > 10000
$i += 1
$j = 0
Until $i > 100
_list()
Func _list()
$sArray[$list][1] = TimerDiff($begin)
$list += 1
EndFunc
Func _add($a)
$a += 29
$a -= 28
EndFunc
_ArrayDisplay($sArray)
|