Reputation: 56
I'm using performTaskWithPathArgumentsTimeout in my ios ui script, and there seems to be a hidden 1 sec delay introduced before executing the command.
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);
outputs: duration: 1001
It the same for all commands. Instant when launched from command line, but they have this 1 sec delay when launched via performTask.
Any idea on how to reduce this delay ?
Upvotes: 2
Views: 960
Reputation: 7170
This has been cleverly solved by the instruments-without-delay project which changes Instruments to remove the 1 second delay in UIAHost.performTaskWithPathArgumentsTimeout
Upvotes: 2
Reputation: 1341
This delay is related to the way UI Automation launches the command internally. There isn't anything we can do from our end.
That said, if you have a lot of commands you are trying to execute in sequence, you can put them all in a shell script and execute it like so:
host.performTaskWithPathArgumentsTimeout("/bin/bash", ["some_shell_script.sh"], 5);
That will run the given shell script file within bash and you'll only have to pay the 1 second process startup penalty once.
Upvotes: 2