【问题标题】:Measure the time in sikuli用 sikuli 测量时间
【发布时间】:2022-01-19 10:59:54
【问题描述】:

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

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

【问题讨论】:

    标签: sikuli-script sikuli-ide


    【解决方案1】:

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

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

    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
    

    【讨论】:

      猜你喜欢
      • 2012-03-28
      • 2012-10-20
      • 2016-04-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-09
      • 1970-01-01
      相关资源
      最近更新 更多