d0n 0 Posted June 24, 2010 So i was wondering which one is faster if i want to do something like this: Check a bunch of string with StringRegExp, would it be faster to 1) Use for loop and loop till i get the correct string then exitloop OR 2) using Select Case to filter through to find the correct string For sure using the for loop will produce a much cleaner code, however i am interested in which one provides better speed thanks for help Share this post Link to post Share on other sites
enaiman 16 Posted June 24, 2010 You can find that by yourself - just time the execution for both and see which is faster. Faster or slower depends on what code you have inside these loops. You can see what difference it makes when you comment/uncomment $ttt=1 in the For/Next loop. $str = "" For $i = 1 to 100000 $str &= Chr(Random(97, 121, 1)) Next $str &= "z" $CharARR = StringSplit($str, "") $forTIME = TimerInit() For $i = 1 to $CharARR[0] ;$ttt = 1 If $CharARR[$i] = "z" Then ExitLoop Next ConsoleWrite("For: "&TimerDiff($forTIME)&@CRLF) $i = 1 $SelectTIME = TimerInit() Do $i += 1 Until $CharARR[$i] = "z" ConsoleWrite("Do: "&TimerDiff($SelectTIME)&@CRLF) So - to answer your question: it depends on the code you want to use - test and see. SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example scriptwannabe "Unbeatable" Tic-Tac-ToePaper-Scissor-Rock ... try to beat it anyway :) Share this post Link to post Share on other sites