How to make scripts faster beyond mouse delay of 0

Asked by matt

Hi,

Apologies if this has been asked before, couldn't find any topics on it.
I appreciate Sikuli has a lot of image processing to do, but is it possible to reduce the delay/pause between each step? I have the mouse delay on 0, but that 1 second pause between each step really adds up to a lot.

Thanks,
Matt

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

Since you already have the mouse delay on 0, I guess you are talking about the time, that takes Sikuli to find something on the screen - and that is not a pause, it is simply processing of tons of pixel information, that have to be compared (using OpenCV features).

This time can only be reduced, if you are able to restrict the region, inside that Sikuli has to search for something (e.g. the app window). Or you avoid searching at all by calculating the next click point based on some known geometric aspects of your GUI.

On an average modern machine it takes Sikuli about 1 second in the average to find something on the whole screen (about 20 inch) or even slightly more.

Reducing the search region to about a quarter of the screen size might cut the search time to the half or even slightly less.

The optimum I have achieved with reasonable effort to restrict the search region (areas of about 50K to 100K pixels) was 0.1 to 0.2 seconds (so to give you the challenge ;-)

faq 1607 might be of interest in this context.

Revision history for this message
matt (mattcmf) said :
#2

Thanks for the excellent and quick response Raiman.

Reducing the search area sounds like a great idea, my issue though is that I have large text boxes with no identifiable features within half the screen! E.g. the drop down button far right, text far left.

I've read in the docs it currently searches 3 times every second. Does this then mean, the search is limited to one second, or after the third search the item is selected? If so is it possible to change the parameters of either the minimal time (instead of 1 second, 0.5 seconds) or instead of 3 per searches then locating. Going on the first or second search?

Revision history for this message
RaiMan (raimund-hocke) said :
#3

These "scan rates" are only relevant, when you are waiting for something to appear. You might reduce the scan rate to reduce Sikuli's cpu usage during these "unsuccessful" searches (if you know, you have to wait for something 10 seconds, it might be enough to try every second only).

If you say nothing else, the standard waiting time is 3 seconds.

You might check your search performance in your case by using:

start = time.time()
print exists("some-image.png", 0) # prints the match if found
print time.time()-start # search time in seconds

The exists() with second parameter as 0 searches only once (on the whole screen in this case).

using reg.exists() with some restricted Region would show you the possible increase in performance.

Nevertheless, it is always worth to check ANY possibilities to restrict the region somehow, search for a few key visuals and try to calculate the rest based on some known geometric aspects of your GUI.

If you send me your script and a screenshot zipped together to my mail at https://launchpad.net/~raimund-hocke, I will have a look at it.

Can you help with this problem?

Provide an answer of your own, or ask matt for more information if necessary.

To post a message you must log in.