prazetto Posted February 26, 2011 Share Posted February 26, 2011 (edited) How the best way to test speed of my UDF's or Functions?Yeah, Here.. here.. I have... Lets go to play....Initial : Speed value of first calling function.Lowest. : Speed value of lowest calling function.Fastest : Speed value of fastest calling function.Average : Speed value of average calling function.Lower value mean fastest execution time and called Fastest.Higher value mean lowest execution time and called lowest.speedtest.au3expandcollapse popup; 15 Jan 2011 #include <yourUDFs.au3> ConsoleWrite(speedtest(100)) Func speedtest($lap=100000) Local $test Local $loop, $start, $dif, $procent, $avg = 0 Local $initial, $fastest = 0.9, $lowest = 0.00000000000000001 For $loop = 1 To $lap $start = TimerInit() $test = apistrtolower("SPEEDTEST") ; CHANGE! This line with your functions UDF's to test the speed $dif = TimerDiff($start) If $loop == 1 Then $initial = $dif If $lowest <= $dif Then $lowest = $dif If $fastest >= $dif Then $fastest = $dif $avg += $dif $procent = Floor($loop / $lap * 100) ConsoleWrite($dif & " " & processbar($procent,100) & " " & $procent & "%" & @CRLF) Next $avg = $avg / $lap Return "Initial: " & $initial & " ms"& @CRLF &"Lowest.: " & $lowest & " ms"& @CRLF &"Fastest: " & $fastest & " ms" & @CRLF &"Average: " & $avg & " ms" & @CRLF EndFunc Func processbar($val, $nval,$nbar=25) Local $lim = Floor($nval / $nbar), $ret $ret = str_repeat(":",$val / $lim) $ret = "." & $ret & str_repeat(" ",Floor($nbar - StringLen($ret))) & "." Return $ret EndFunc Func str_repeat($input, $multiplier=0) Local $str, $loop $str = "" If $multiplier >= 1 Then For $loop = 1 To $multiplier Step +1 $str &= $input Next EndIf Return $str EndFuncyourUDFs.au3#include-once Local $initial = DllOpen("user32.dll") Func apistrtolower($str) $str = DllCall($initial,"wstr","CharLowerW","wstr",$str) Return $str[0] EndFunc Func apistrtolower2($str) $str = DllCall("user32.dll","wstr","CharLowerW","wstr",$str) Return $str[0] EndFuncDownload as single rar file: speedtest.rarapistrtolower()Initial : 0.0507222118056147 msLowest. : 0.0534971960386589 msFastest: : 0.0194548894608553 msAverage: : 0.020928256089454 msapistrtolower2()Initial : 0.0525597013653332 msLowest. : 0.0822332827654388 msFastest : 0.0231298685802922 msAverage : 0.0246274225714627 msMore example of the return value of speed test,StringCompare()StringCompare($string1, $string2, 0)Average : 0.00258000293182151StringCompare($string1, $string2, 2) <-- BetterAverage : 0.00247875281676456StringInStr()StringInStr($string,$substring,0,$occurrence, $start, $count) <-- BetterAverage : 0.00486000552273355StringInStr($string,$substring,2,$occurrence, $start, $count)Average : 0.00504750573580197StringReplace()StringReplace($string, $searchstring_start, $replacestring, $occurrence, 0)Average : 0.00686625780256568StringReplace($string, $searchstring_start, $replacestring, $occurrence, 2) <-- BetterAverage : 0.00459000521591502 Edited March 7, 2011 by prazetto # Button. Progressbar - Graphical AutoIt3 Control (UDF) # GTK on AutoIt3 - GTK+ Framework | Widgets cig computer instruction graphics http://code.hstn.me Link to comment Share on other sites More sharing options...
netegg Posted February 26, 2011 Share Posted February 26, 2011 how about a full script? 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