Appium-ios-xctest-performance

Automating Performance Metrics Measurement

Apple provides the instruments tool with quite a rich set of features for desktop and mobile applications performance measurement. The collected data can be then visualized with Instruments.app, which is a part of Xcode DevTools. By default Xcode provides several measurement templates, like Activity Monitor or Time Profiler, but one can also create their own profiles and select a custom set of metrics to record and visualize. Read https://developer.apple.com/library/content/documentation/DeveloperTools/Conceptual/InstrumentsUserGuide to get a more detailed overwiew of available tool features.

mobile: startPerfRecord

This command starts the performance recorder for the given profile name (template) on the device under test. In case this command is called two or more times in a row then the previous recorder will be forcefully stopped and the new one will start. All the previous data will be lost.

Important: It is expected that the appropriate security flag is set from the Appium server command line in order to measure Simulator performance, since the instruments tool records the data from all running processes on the host machine.

Supported arguments

  • timeout: For how long the recorder should be running in milliseconds. 5 minutes by default. Try not to set too high a value to this argument, since .trace files generated by instruments are pretty big in size.
  • profileName: The name of an existing performance template. Activity Monitor by default.
  • pid: The ID of the process to meassure the performance for. Set it to current in order to meassure only the performance of the process, which belongs to the currently active application (this might not work for some profiles). All processes running on the device are meassured if process ID is unset (the default setting). Setting process ID while device under test is Simulator might require instruments to be launched with sudo privileges, which is not supported and will throw a timeout exception.

Usage examples

// Java
Map<String, Object> args = new HashMap<>();
args.put("timeout", 60 * 1000);
args.put("profileName", "Time Profiler");
driver.executeScript("mobile: startPerfRecord", args);

mobile: stopPerfRecord

This command stops performance recorder for the given profile name (template) on the device under test and returns the collected data in zipped format or uploads it to a remote server. An exception will be thrown if startPerfRecord command has not been invoked before.

Important: It is expected that the appropriate security flag is set from the Appium server command line in order to measure Simulator performance, since the instruments tool records the data from all running processes on the host machine.

Supported arguments

  • profileName: The name of an existing performance template, for which the monitoring has been running before. Activity Monitor by default.
  • remotePath: The path to a remote location, where the resulting zipped .trace file should be uploaded. The following protocols are supported: http/https, ftp. Null or empty string value (the default setting) means the content of resulting file should be zipped, encoded as Base64 and passed as the return value. An exception will be thrown if the generated file is too big to fit into the available server process memory.
  • user: The name of the user for the remote authentication. Only works if remotePath is provided.
  • pass: The password for the remote authentication. Only works if remotePath is provided.
  • method: The http multipart upload method name. Only works if remotePath is provided. Equals to PUT by default.

Usage examples

# Python
driver.execute_script('mobile: stopPerfRecord', {
    'profileName': 'Time Profiler',
    'remotePath': 'ftp://myserver/upload/',
    'user': 'serveruser',
    'pass': 'secretpass'
})

官方链接为:http://appium.io/docs/en/writing-running-appium/ios/ios-xctest-performance