让它们运行同样的循环百万次
时间差别居然:前者比后者快多一倍时间了
Local $iTimer, $iVar = 1
$iTimer = TimerInit()
For $i = 1 To 1000000
If $iVar Then $iVar = 1
Next
ConsoleWrite(Round(TimerDiff($iTimer), 2) & @CRLF)
$iTimer = TimerInit()
For $i = 1 To 1000000
If $iVar Then
$iVar = 1
EndIf
Next
ConsoleWrite(Round(TimerDiff($iTimer), 2) & @CRLF)
;=======================================================
$iVar = 0
$iTimer = TimerInit()
For $i = 1 To 1000000
If Not $iVar Then $iVar = 0
Next
ConsoleWrite(Round(TimerDiff($iTimer), 2) & @CRLF)
$iTimer = TimerInit()
For $i = 1 To 1000000
If Not $iVar Then
$iVar = 0
EndIf
Next
ConsoleWrite(Round(TimerDiff($iTimer), 2) & @CRLF)
|