0

我正在尝试自动化和测量应用程序和一些用例的性能。应用程序通过 VNC 启动远程服务器并在远程服务器上执行一些用户操作。我们计划在这个测试中使用 sikuli 和 python。我对 sikuli 很陌生。

如何测量 sikuli 中用户操作的时间?例如,我单击远程服务器屏幕上的一个按钮,然后启动另一个屏幕。如何衡量这个?

4

1 回答 1

0

我认为你可以做这样的事情 start = time.time() is not a timer。它只是将处理此语句时的时间存储到值开始中。因此,稍后在您可以访问变量 start 的地方,您可以检查自 start 以来经过的时间: elapsed = time.time() - start

因此,无需进入子处理甚至事件处理,您需要一个函数来启动一个新的计时器,并且可以询问给定时间是否已过以及计时器值的全局存储。

basic timer function:

def timer(name, elapse=0):
    if elapse > 0: # we start a timer
        exec("Settings.myTimer" + str(name) + "=time.time()+" + str(elapse)
    else # we check the timer
        rest = eval("Settings.myTimer" + str(name)) - time.time()
        if rest > 0: return False # not yet elapsed
        else return True

usage:
timer(1, 100) will start now and elapse in 100 seconds
# ... some code
if timer(1): print "timer1: time is over"

As global storage for the timer values I use the Sikuli Settings class.

Since the timer not really does anything, it is just storing a value for later comparison, you do not need a "reset".

just repeating the above sequence would give a new value to Settings.myTimer1
于 2021-12-16T11:33:17.727 回答