【问题标题】:how to remove the 1sec delay of performTaskWithPathArgumentsTimeout如何消除 performTaskWithPathArgumentsTimeout 的 1 秒延迟
【发布时间】:2012-04-25 16:11:24
【问题描述】:

我在我的 ios ui 脚本中使用 performTaskWithPathArgumentsTimeout,在执行命令之前似乎引入了隐藏的 1 秒延迟。

var target = UIATarget.localTarget();
var host = target.host();

var start = new Date().getTime();
var result = host.performTaskWithPathArgumentsTimeout("/bin/echo", ["Hello World"], 5);
var total = new Date().getTime() - start;

UIALogger.logDebug("duration: " + total);

输出: 持续时间:1001

所有命令都一样。从命令行启动时立即生效,但通过 performTask 启动时会有 1 秒的延迟。

关于如何减少这种延迟的任何想法?

【问题讨论】:

    标签: ios instruments ui-automation ios-ui-automation


    【解决方案1】:

    此延迟与 UI 自动化在内部启动命令的方式有关。从头到尾,我们无能为力。

    也就是说,如果您有很多命令要按顺序执行,您可以将它们全部放在一个 shell 脚本中并像这样执行它:

    host.performTaskWithPathArgumentsTimeout("/bin/bash", ["some_shell_script.sh"], 5);
    

    这将在 bash 中运行给定的 shell 脚本文件,您只需支付 1 秒的进程启动惩罚一次。

    【讨论】:

      【解决方案2】:

      instruments-without-delay 项目巧妙地解决了这个问题,该项目更改了 Instruments 以消除 UIAHost.performTaskWithPathArgumentsTimeout 中的 1 秒延迟

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2021-12-26
        • 1970-01-01
        • 1970-01-01
        • 2010-10-29
        • 1970-01-01
        • 1970-01-01
        • 2014-09-11
        相关资源
        最近更新 更多