#cs ---------------------------------------------------------------------------- FastFind Version: 1.8 AutoIt Version: 3.3.6.1 Author: FastFrench, Smoothed out by LeCarre Script Function: FastFind simple Benchmark. #ce ---------------------------------------------------------------------------- #include #include "FastFind.au3" ; In order to acheive full possible speed, I disable all debug features FFSetDebugMode(0) Global $Timer Global $MainWindow, $Label[12] MakeGUI() QueueTests() RunApp() Func RunApp() Local $msg While 1 $msg = GUIGetMsg(1) $msgbuff = $msg[0] Switch $msg[0] Case $GUI_EVENT_CLOSE If $msg[1] = $MainWindow Then ExitLoop EndIf EndSwitch WEnd EndFunc Func MakeGUI() $MainWindow = GUICreate("Benchmark",500,250,-1,-1) GUISetBkColor(0xFFFFFF) GUISetFont(10,Default,Default,"Courier New") for $i = 0 to 11 $Label[$i] = GUICtrlCreateLabel("",5,5 + 20*$i,500,20) Next GUICtrlSetData($Label[0],"Test Avg Speed Calls") GUISetState(@SW_SHOW ,$MainWindow) EndFunc func QueueTests() $Timer = TimerInit() RunTests(1,500) RunTests(2,100) RunTests(3,500) RunTests(4,500) RunTests(5,100) RunTests(6,100) RunTests(7,500) RunTests(8,200) RunTests(9,100) RunTests(10,100) GUICtrlSetData($Label[11],"All Tests Complete in " & Round(TimerDiff($Timer)/1000,2) & " Seconds.") GUISetBkColor(0xBAD1ED) EndFunc Func RunTests($i,$iterate) Local $Start = TimerInit(), $Test, $Desc switch $i case 1 ; Use Native Pixelgetcolor() on 100 different points $Test = "PixelGetcolor" GUICtrlSetData($Label[$i],"Running... " & $Test) $Start = TimerInit() for $x = 1 to $iterate $a = PixelGetcolor($x, 500); Next Results($Test,$iterate,TimerDiff($Start),$i) Case 2 ; Use Native PixelSearch() on FullScreen (1920x1080) x 100 with ShadeVariation $Test = "PixelSearch" GUICtrlSetData($Label[$i],"Running... " & $Test) $Start = TimerInit() for $x = 1 to $iterate $a = PixelSearch(0,0,1919,1079, 0x00FF5511, 2); Next Results($Test,$iterate,TimerDiff($Start),$i) Case 3 ; Processing time comparaison with FastFind equivalent : FFGetPixel, that works on a SnapShot. $Test = "FFGetPixel" GUICtrlSetData($Label[$i],"Running... " & $Test) $Start = TimerInit() FFSnapShot() ; To keep it simple, a FullScreen capture here for $x = 1 to $iterate/2 for $y = 0 to 1 ; Func FFGetPixel($x, $y, $NoSnapShot=$FFLastSnap) $a = FFGetPixel($x, 500); Next Next Results($Test,$iterate,TimerDiff($Start),$i) Case 4 ; Same with direct dll call => nearly 40% faster $Test = "GetPixel DllCall" GUICtrlSetData($Label[$i],"Running... " & $Test) $Start = TimerInit() FFSnapShot() ; To keep it simple, a FullScreen capture here for $x = 1 to $iterate/3 for $y = 0 to 2 DllCall($FFDllHandle, "int", "FFGetPixel", "int", $x, "int", 500, "int", $FFLastSnap) Next Next Results($Test,$iterate,TimerDiff($Start),$i) Case 5 ; SnapShot BenchMark : SnapShots of 10x10 areas $Test = "FFSnapShot 10x10" GUICtrlSetData($Label[$i],"Running... " & $Test) $Start = TimerInit() for $x = 1 to $iterate ;Func FFSnapShot(const $Left=0, const $Top=0, const $Right=0, const $Bottom=0, const $NoSnapShot=$FFDefaultSnapShot, const $WindowHandle=-1) $a = FFSnapShot(0,0,9,9) ; 10x10 pixels area Next Results($Test,$iterate,TimerDiff($Start),$i) Case 6 ; SnapShot BenchMark : FullScreen SnapShots $Test = "FFSnapShot Fullscreen" GUICtrlSetData($Label[$i],"Running... " & $Test) $Start = TimerInit() for $x = 1 to $iterate ;Func FFSnapShot(const $Left=0, const $Top=0, const $Right=0, const $Bottom=0, const $NoSnapShot=$FFDefaultSnapShot, const $WindowHandle=-1) $a = FFSnapShot() ; FullScreen Capture Next Results($Test,$iterate,TimerDiff($Start),$i) Case 7 ; FFNearestPixel BenchMark : simple pixel search in 200x200 area $Test = "FFNearestPixel (200x200)" GUICtrlSetData($Label[$i],"Running... " & $Test) $Start = TimerInit() $a = FFSnapShot(0,0,199,199) ; 200x200 pixels for $x = 1 to $iterate ; Func FFNearestPixel($PosX, $PosY, $Color, $ForceNewSnap=true, $Left=0, $Top=0, $Right=0, $Bottom=0, $NoSnapShot=$FFLastSnap, $WindowHandle=-1) $a = FFNearestPixel($x,$x,0x002545FA,false) ; Pixel search in 200x200 area, don't force SnapShots each time Next Results($Test,$iterate,TimerDiff($Start),$i) Case 8 ; FFNearestPixel BenchMark : pixel search in FullScreen and ShadeVariation $Test = "FFNearestSpot (Full+Shaded)" GUICtrlSetData($Label[$i],"Running... " & $Test) ; As NearestPixel do not expose ShadeVariation, we use FFNearestSpot($SizeSearch, $NbPixel, $PosX, $PosY, $Color, $ShadeVariation=0, $ForceNewSnap=true, $Left=0, $Top=0, $Right=0, $Bottom=0, $NoSnapShot=$FFLastSnap, $WindowHandle=-1) $Start = TimerInit() $a = FFSnapShot() ; FullScreen for $x = 1 to $iterate ; Func FFNearestSpot($SizeSearch, $NbPixel, $PosX, $PosY, $Color, $ShadeVariation=0, $ForceNewSnap=true, $Left=0, $Top=0, $Right=0, $Bottom=0, $NoSnapShot=$FFLastSnap, $WindowHandle=-1) $a = FFNearestSpot(1, 1, $x, $x, 0x00FF5511, 2, false) Next Results($Test,$iterate,TimerDiff($Start),$i) Case 9 ; FFNearestPixel BenchMark : simple pixel search in 200x200 area $Test = "ComplexFullScreenSearch" GUICtrlSetData($Label[$i],"Running... " & $Test) $Start = TimerInit() $a = FFSnapShot() ; FullScreen Capture FFAddColor(0x453456) FFAddColor(0xFF0034) FFAddColor(0x76FF98) FFAddColor(0x8723FF) FFAddColor(0x771122) FFAddExcludedArea(5,10,10,15) FFAddExcludedArea(52,52,80,80) FFAddExcludedArea(120,130,100,180) for $x = 1 to $iterate ; Func FFNearestSpot($SizeSearch, $NbPixel, $PosX, $PosY, $Color, $ShadeVariation=0, $ForceNewSnap=true, $Left=0, $Top=0, $Right=0, $Bottom=0, $NoSnapShot=$FFLastSnap, $WindowHandle=-1) $a = FFNearestSpot(20, 50, 100, 100, -1, 10, false) ; With ShadeVariation, don't force SnapShots each time Next Results($Test,$iterate,TimerDiff($Start),$i) Case 10 $Test = "ExtremeComplexFullScreenSearch" GUICtrlSetData($Label[$i],"Running... " & $Test) $Start = TimerInit() for $x = 1 to $iterate ; Func FFBestSpot($SizeSearch, $MinNbPixel, $OptNbPixel, $PosX, $PosY, $Color, $ShadeVariation=0, $ForceNewSnap=true, $Left=0, $Top=0, $Right=0, $Bottom=0, $NoSnapShot=$FFLastSnap, $WindowHandle=-1) $a = FFBestSpot(20, 2, 50, 100, 100, -1, 10, false) ; Same as before, but can accept down to 2 pixels only instead of 50 Next Results($Test,$iterate,TimerDiff($Start),$i) EndSwitch EndFunc Func Results($Test,$i,$ms,$index) GUICtrlSetData($Label[$index],Pad($Test,30) & " " & TimeSpan($ms,$i) & " " & Pad($i,5) & "Calls") ConsoleWrite(Pad($Test,30) & " x " & Pad($i,5) & "in " & Pad(Round($ms/1000,4) & "00",6) & "s" & @LF) EndFunc func Pad($text,$size) Local $Pad = " " return StringLeft($text & $Pad,$size) EndFunc Func TimeSpan($dif, $Nb) $res = $dif/$Nb return Pad(Round($res,4),5) & " ms " EndFunc ; Results : PixelGetColor x 500 = 9.61 Seconds ; FFGetPixel x 500 = 0.0893 Seconds ; My Results ;~ PixelGetcolor x 500 in 0.0545s ;~ PixelSearch x 100 in 1.9835s ;~ FFGetPixel x 500 in 0.0141s ;~ GetPixel DllCall x 500 in 0.0098s ;~ FFSnapShot 10x10 x 100 in 0.0049s ;~ FFSnapShot Fullscreen x 100 in 0.6907s ;~ FFNearestPixel (200x200) x 500 in 0.0174s ;~ FFNearestSpot (Full+Shaded) x 200 in 1.5561s ;~ ComplexFullScreenSearch x 100 in 6.4877s ;~ ExtremeComplexFullScreenSearch x 100 in 10.397s