【问题标题】:Correct usage of the "--throttle" parameter of monkey?正确使用monkey的“--throttle”参数?
【发布时间】:2018-01-07 00:11:01
【问题描述】:

我无法通过monkey 设置生成事件之间的间隔。 The official documentation--throttle 的用法定义为 "在事件之间插入固定延迟。您可以使用此选项来减慢 Monkey。如果未指定,则没有延迟,并且事件会尽快生成。”

我需要生成 500 个事件,它们之间的间隔为 1 秒

这是我用过的:

monkey -v --throttle 1000 -p com.estrongs.android.pop 500

因此,该过程至少需要 1000*500 毫秒,这意味着 超过 8 分钟。但这项工作在几秒钟内完成。

有什么我想念的吗? monkey工具产生的事件间隔如何设置?

【问题讨论】:

    标签: android android-emulator adb monkeyrunner monkey


    【解决方案1】:

    monkey一组事件之后注入指定的延迟。您只能指定一种类型的事件和时间,命令和结果将符合预期。

    time monkey -v -v -v --throttle 2000 --pct-touch 100 -p  com.estrongs.android.pop 50
    

    这将打印一些消息,例如

    ...
    Sleeping for 2000 milliseconds
    :Sending Touch (ACTION_DOWN): 0:(669.0,1746.0)
    :Sending Touch (ACTION_UP): 0:(658.455,1740.9874)
    Sleeping for 2000 milliseconds
    :Sending Touch (ACTION_DOWN): 0:(617.0,436.0)
    :Sending Touch (ACTION_UP): 0:(616.7584,433.1081)
    Sleeping for 2000 milliseconds
    :Sending Touch (ACTION_DOWN): 0:(529.0,1399.0)
    :Sending Touch (ACTION_UP): 0:(529.58325,1405.1238)
    Sleeping for 2000 milliseconds
    :Sending Touch (ACTION_DOWN): 0:(46.0,551.0)
    :Sending Touch (ACTION_UP): 0:(52.594234,557.6963)
    Sleeping for 2000 milliseconds
    :Sending Touch (ACTION_DOWN): 0:(1004.0,1706.0)
    Events injected: 50
    

    然后time:

    0m50.30s real     0m00.20s user     0m00.04s system
    

    表示预期的大约 50 秒 (50*2000/2),2 因为它发送 DOWN & UP。

    【讨论】:

      猜你喜欢
      • 2020-05-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-26
      • 2014-12-03
      • 2020-12-13
      • 2011-10-21
      • 1970-01-01
      相关资源
      最近更新 更多