首页 > 解决方案 > 使用 Xcode 12 xctrace 命令行工具为 iOS 自动分析

问题描述

我正在尝试使用 Xcode 12 Instruments 开发工具自动化性能测试,需要一些帮助。

我想将 .trace 文件解析为可读格式,并想在控制台上打印泄漏/CPU 使用情况。我正在使用下面的 xctrace 命令行来使用 Xcode 12 Instruments 工具自动进行泄漏/时间分析:

xcrun xctrace record --device "udid" --template "Leaks" --time-limit 10m --attach "PID" --output "xyz.trace"

xcrun xctrace export --input "xyz.trace" toc --output "xyz.xml"

如果有人可以提供帮助,那就太好了。

跟踪文件供参考:https ://gofile.io/d/EpvOXa

标签: iosswiftxcodememory-leaksinstruments

解决方案


我不确定我是否正确理解了您的问题,但是如果我运行您的命令,我会收到一条错误消息。CLI 工具给了我以下说明:

usage: xctrace export [<options>] [--toc | --xpath expression]

description:
    Export given .trace using supplied query to the XML file format that can be later read and post-processed

options:
    --input <file>              Export data from the given .trace file
    --output <path>             Command output is written to the given path, if specified
    --toc                       Present entities to export in the table of contents form
    --xpath <expression>        Choose elements to export using specified XPath expression

notes:
    If output path is not specified, the export operation output will be written to the standard output.
    Table of Contents and XPath query are two separate modes and they cannot be specified together.

examples:
    xctrace export --input input.trace --toc
    xctrace export --input input.trace --toc --output table_of_contents.xml
    xctrace export --input input.trace --xpath '/trace-toc/run[@number="1"]/data/table[@schema="my-table-schema"]'

据此,参数 toc 缺少两个破折号。我希望这会为你解决这个问题。


推荐阅读