Detect run-time sequential actions

Asked by born

Hello!
I can not find a way to set the timer to count the number of seconds a few steps performed by the script.
How do I do?

Sikuli run on Windows XP.

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
born
Solved:
Last query:
Last reply:

This question was reopened

  • by born
Revision history for this message
RaiMan (raimund-hocke) said :
#1

you have to import the python module time.

about its functions you can find appropriate information on the official python home page:
http://www.python.org/

If you then need further help, you are welcome to come back with your questions and scripts.

Revision history for this message
born (born127) said :
#2

Hello
I tried to time the module simply remove the current date. But I did not succeed.
Here is my code:

import time

import datetime

a = time.clock()

popup(a)

But the message sikuli:

[sikuli] click on (206,720), MOD: 0

[sikuli] нЯРЮМНБКЕМН

[sikuli] нЬХАЙЮ ОПНХЯУНДХР МЮ ЯРПНЙЕ 4

[sikuli] яННАЫЕМХЕ НА НЬХАЙЕ:

Traceback (most recent call last):

  File "C:\DOCUME~1\SEMENO~1\LOCALS~1\Temp\sikuli-tmp802358763321957841.py", line 4, in <module>

    popup(a)

  File "C:\Program Files\Sikuli\sikuli-script.jar\Lib\sikuli\Sikuli.py", line 133, in popup

TypeError: popup(): 1st arg can't be coerced to String

Sorry, I still do not understand python.

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

Ok, no problem not knowing much Python:

When testing, you should use the more userfriendly "print" which tries to convert everything into a string and writes it to the message area.
popup() needs a text and your "a=time.clock()" is a number.

try this:
import time
a = time.strftime("%H:%S")
popup("The time now is: " + a)

strftime(): if nothing else said converts the actual time to a string according to the given formatting string
(look here: http://docs.python.org/library/time.html about the middle of the page)

Revision history for this message
born (born127) said :
#4

Thank you
I made easier when he discovered that the print output appears at the bottom, the tab "Message".

import time

a = time.clock()
wait(img)
print "Run time: ", time.clock() - a, " seconds"

I now have the opportunity to pinpoint duration of the tests:)

Revision history for this message
born (born127) said :
#5

problem Solved