Code: Select all
CritObj := CriticalObject()
CritObj.found:=1
threads=
(%`
#persistent
#notrayicon
#NoEnv
#MaxHotkeysPerInterval 99000000
#HotkeyInterval 99000000
#KeyHistory 0
ListLines Off
Coordmode, pixel, screen
Coordmode, mouse, screen
Coordmode, tooltip, screen
asd:=0
loop
{
if (CritObj.found=0)
{
starttime:=a_tickcount
ImageSearch, asdx, asdy, 0, 0, 100, 100, %Image%
tooltip, % a_tickcount-starttime, % number*50
break
}
sleep, 10
}
return
)
loop, 20
asd := AhkThread("CritObj:=CriticalObject(" &CritObj ")`nImage=test" a_index ".png`nnumber:=" a_index "`n" threads)
return
f2::
CritObj.found:=0
return
When I change CritObj.found to 0 those threads perform an image search and then break and sleep because they are #persistent. They will show the result in tooltips.
For some reason the time it takes for each thread to perform the imagesearch is huge compared to 1 imagesearch performed with an ahk script.
Doing the same Imagesearch once on 1 normal script takes: 11ms
Doing the same Imagesearch with 5 threads at the same time takes: average of 62ms each
Doing the same Imagesearch with 10 threads at the same time takes: average of 86ms each
Doing the same Imagesearch with 20 threads at the same time takes: average of 175ms each
This is not hardware related as I'm using an i5 8400, gtx 1060 6gb, 16gb ram and an ssd. The CPU Consumption doesn't go past 5%
Can Imagesearch be causing the issue? Like multiple imagesearches are slowing each other? or is this something related to threads slowing each other?
Thanks in advance