← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #156879]: time.time(), Set max value to variable

 

Question #156879 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/156879

    Status: Open => Answered

RaiMan proposed the following answer:
Not really clear what you mean :-(

this e.g. would collect the elapsed times between checkpoints

timeCollect = [time.time()] # time at start
# some time consuming script statements
timeCollect.append(time.time()) # time at checkpoint added to list
# some time consuming script statements
timeCollect.append(time.time()) # time at checkpoint added to list
# some time consuming script statements
timeCollect.append(time.time()) # time at checkpoint added to list
# some time consuming script statements
timeCollect.append(time.time()) # time at checkpoint added to list
# some time consuming script statements
timeCollect.append(time.time()) # time at checkpoint added to list

to get your results e.g.
print "total time=", timeCollect[-1]-timeCollect[0]

and a list of the intermediate elapsed times:
for i in range(len(timeCollect)):
   tt = timeCollect[i+1]-timeCollect[0]
   ts = timeCollect[i+1]-timeCollect[i]
   print "Checkpoint %d: %d total eleapsed -- %d elapsed since previous"%(i+1,tt, ts)

Is it what you want?

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.