Performance slowdown

Asked by Joe Tibbetts

Thanks for your help prior RaiMan! The script finally works but I am hitting performance degradation really fast.

Always at the 4th iteration of the "for" loop, Sikuli slows to a crawl. The cursor will sit there and image matching will time out mostly. I've tried to optimize search Region as much as possible. I've tried closing everything in the computer and just running Sikuli and browser. The wheel() function and the if() function aren't called within the for loop, so the slowdown is caused by those.

I am on Sikuli 1.1.0 on OS X 10.10.1.
Any help much appreciated!

setAutoWaitTimeout(3)
setFindFailedResponse(SKIP)
Settings.MoveMouseDelay = 0
Settings.WaitScanRate = 10

aaFirstlink = Region(0,0,422,137)
aaProfile = Region(165,195,87,32)
itWSR = Region(35,450,222,213)
itASR = Region(20,380,260,180)
closeTR = Region(23,22,28,31)
passwdR = Region(460,150,500,300)
rightclickR = Region(0,0,800,700)

lineHeight = 48
link = aaFirstlink.find("1424991213367.png").offset(Location(2, 30))
for i in range(7):
    App.focus("safari")
    if (i != 0) and (i % 10 == 0):
        wheel(aaFirstlink.getLastMatch(), WHEEL_UP, 12)
        link = aaFirstlink.getLastMatch().offset(Location(0, 30))
    link.rightClick()
    wait("1425009381807.png")
    click()
    aaProfile.wait("1424834582178.png",10)
    click(aaProfile.getLastMatch())
    wait(2)
    itWSR.wait("1424835540285.png")
    click(itWSR.getLastMatch())
    App.focus("iTunes")
    wait(3)
    itASR.click("1422904493043.png")
    if passwdR.exists("1422744785839.png",1):
        type(getLastMatch(),"xxxxxxx")
        if exists("1422744848431.png",1):
            click()
        if exists ("1423777812879.png",1):
            click()
    App.focus("safari")
    wait(2)
    closeTR.click("1425009533953.png")
    wait(2)
    link.y += lineHeight

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
Joe Tibbetts (otau1983) said :
#1

I tested it some more. What I found was weird - the slow down seems to correlated with how long Sikuli has been running which is about a minute. I did the test by changing the last wait(2) to wait(50) to see let remaining scans if any to finish before running the next loop iteration. Basically, with wait(50), the slow down happens in the 2nd loop iteration.

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

-- setFindFailedResponse(SKIP)
This suppresses any FindFailedd reporting.
So how do you realise "image matching will time out mostly"?

-- The wheel() function and the if() function aren't called within the for loop, so the slowdown is caused by those.
what do you mean by that?
They are indeed inside the loop.

-- so what do you mean by slowdown?
... that the cursor does not move anymore?
if yes, then together with the switching-findfailed-off and using the getLastMatch() feature the cursor will not move in case of find failed (which is skipped), since there is no new last match.

So to get nearer to the problem, you should eliminate the setFindFailedResponse(SKIP) and replace the wait(image) with exist(image) (which suppresses a FindFailed exception and hence can be used with if).
In the places, where having a new match is vital, you should then either use wait(image) or if not exist(image): and do something that makes sense.

Revision history for this message
Joe Tibbetts (otau1983) said :
#3

I rewrote parts of the code based on your suggestions. I'm still seeing performance degradation after 50 seconds or so.
I made a screen capture video of the problem, here at Youtube. Code below.

https://www.youtube.com/watch?v=Cr_MAVfVWo4

Answers to your questions:

-- The wheel() function and the if() function aren't called within the for loop, so the slowdown is caused by those.
what do you mean by that?

Sorry, I meant "The wheel() function and the if() function aren't called within the for loop, so the slowdown is NOT caused by those"

-- so what do you mean by slowdown? that the cursor does not move anymore?

Yes, as you can see in the video, everything slows down to a crawl. Each action takes tens of seconds to do, if not more.

CODE:

Settings.MoveMouseDelay = 0

aaFirstlink = Region(0,0,422,137)
aaProfile = Region(100,150,200,150)
itWSR = Region(35,450,222,213)
itASR = Region(20,380,260,180)
closeTR = Region(21,23,29,27)
passwdR = Region(460,150,500,300)
rightclickR = Region(0,0,800,700)

lineHeight = 48
if aaFirstlink.exists("1424991213367.png",0):
    link = aaFirstlink.getLastMatch().offset(Location(2, 30))

for i in range(7):
    print i
    App.focus("google chrome")
    if (i != 0) and (i % 10 == 0):
        wheel(aaFirstlink.getLastMatch(), WHEEL_UP, 12)
        link = aaFirstlink.getLastMatch().offset(Location(0, 30))
    link.rightClick()
    wait(1)
    if exists("1425009381807.png",0):
        click()
    wait(3)
    if aaProfile.exists("1425096831076.png",0):
           click(aaProfile.getLastMatch())
    wait(3)
    if itWSR.exists("1424835540285.png",0):
        click(itWSR.getLastMatch())
    App.focus("iTunes")
    wait(2)
    if itASR.exists("1422904493043.png",0):
        click(itASR.getLastMatch())
    if passwdR.exists("1422744785839.png",1):
        type(getLastMatch(),"Otau1983")
        if exists("1422744848431.png",1):
            click()
        if exists ("1423777812879.png",1):
            click()
    App.focus("google chrome")
    wait(1)
    if closeTR.exists("1425009533953.png",0) :
        click(closeTR.getLastMatch())
    wait(2)
    link.y += lineHeight

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

This has nothing to do with performance degradation.
Your script is somehow simply coming out of sequence and hence the wrong find ops are performed, which takes time.

I currently do not have the time to dig deeper into your problem to get on you on the road.

You can send me a zip of your script, so I can see the images you are using and the link of the page you are acting on.
I will then look into it within the next 24 h
my mail at top left of https://launchpad.net/~raimund-hocke

Revision history for this message
Joe Tibbetts (otau1983) said :
#5

RaiMan,
Will do! Thanks so much!!!

Revision history for this message
Launchpad Janitor (janitor) said :
#6

This question was expired because it remained in the 'Needs information' state without activity for the last 15 days.

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

to keep it open

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

to keep it open

Can you help with this problem?

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

To post a message you must log in.