javas Posted January 22, 2009 Share Posted January 22, 2009 I would like to know which one of these codes runs faster as an .exe program(compiled .au3 file): if $a = $b and $a = $c and $a = $d Then ~to be implemented~ endif if $a = $b then if $a = $c then if $a = $d then ~to be implemented~ endif endif endif Link to comment Share on other sites More sharing options...
Inverted Posted January 22, 2009 Share Posted January 22, 2009 I'd be surprised if there was a difference in speed between the two :-) Link to comment Share on other sites More sharing options...
PsaltyDS Posted January 22, 2009 Share Posted January 22, 2009 I would like to know which one of these codes runs faster as an .exe program(compiled .au3 file): if $a = $b and $a = $c and $a = $d Then ~to be implemented~ endif if $a = $b then if $a = $c then if $a = $d then ~to be implemented~ endif endif endif ...so you tested and the results were what? Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Spiff59 Posted January 22, 2009 Share Posted January 22, 2009 Hmm... Dim $a=2, $b=2, $c=2, $d=2 If ($a=$b)+($a=$c)+($a=$d) = 3 Then tooltip(">>> YES <<<") Endif ... nevermind. An interesting solution, but I don't expect it to beat-the-clock. Link to comment Share on other sites More sharing options...
Xand3r Posted January 22, 2009 Share Posted January 22, 2009 $a=1 $b=2 $c=3 $t=TimerInit() For $i=1 To 1000000 If $a+$b=3 And $c-$b=1 And $a=$b/2 Then EndIf Next MsgBox(0 ,"" , TimerDiff($t)) $t=TimerInit() For $i=1 To 1000000 If $a+$b=3 Then If $c-$b=1 Then If $a=$b/2 Then EndIf EndIf EndIf Next MsgBox(0 ,"" , TimerDiff($t)) $t=TimerInit() For $i=1 To 1000000 Select Case $a+$b=3 And $c-$b=1 And $a=$b/2 EndSelect Next MsgBox(0 ,"" , TimerDiff($t)) so.. the nested way is the slowest about 1 sec longer than the long if and the select is about the same as the big if Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro Link to comment Share on other sites More sharing options...
Valuater Posted January 22, 2009 Share Posted January 22, 2009 should have used... $c-$b=$a This is an interesting comment, all by itself.... so.. the nested way is the slowest about 1 sec longer than the long if and the select is about the same as the big if tongue.gif lol 8) Link to comment Share on other sites More sharing options...
javas Posted January 22, 2009 Author Share Posted January 22, 2009 (edited) I ran this code $a=1 $b=2 $c=3 $t=TimerInit() For $i=1 To 10000000 If $a = $b And $a = $c Then EndIf Next MsgBox(0 ,"" , TimerDiff($t)) $t=TimerInit() For $i=1 To 10000000 If $a = $b Then If $a = $c Then EndIf EndIf Next MsgBox(0 ,"" , TimerDiff($t)) first msgbox = 11804.2980322918 second msgbox = 10834.2162900592 I conclude if a = b and a = c most of the time, then one long if statement is faster, but, if a is not equal to b or c most of the time, then a nested is faster. Edited January 22, 2009 by javas Link to comment Share on other sites More sharing options...
Authenticity Posted January 22, 2009 Share Posted January 22, 2009 It would be preferable to take statistical results and reduce the loop to something around 1-30 loops and build an inner loop which will do the main code so some "jumps" won't reduce the overall result and you'll get 20 numbers and min and max and avg:take a look: http://www.autoitscript.com/forum/index.ph...hl=AutoIT+Speed Link to comment Share on other sites More sharing options...
Spiff59 Posted January 23, 2009 Share Posted January 23, 2009 (edited) Just having fun here...It's obvious this doesn't stand a chance when one of the first couple pairs of numbers don't match, since it will continue to make all 4 compares regardless of the values tested, but...I was surprisd to see this smokes (only) the "nested if" method when all 4 numbers are the same:$t=TimerInit()For $i=1 To 1000000 If ($a=$*($a=$c)*($a=$d) Then EndIfNextMsgBox(0 ,"" , TimerDiff($t)) Edited January 23, 2009 by Spiff59 Link to comment Share on other sites More sharing options...
AgentSmith15 Posted January 23, 2009 Share Posted January 23, 2009 This post explains a lot about speed and AutoIthttp://www.autoitscript.com/forum/index.php?showtopic=51604 [center][/center] Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now