[英]Automate profiling for iOS using Xcode 12 xctrace command line tools
I am trying to automate performance testing using Xcode 12 Instruments developer tool and need some help.我正在尝试使用 Xcode 12 Instruments 开发人员工具自动执行性能测试,需要一些帮助。
I want to parse.trace file into readable format and want to print leaks/CPU usage on console.我想将 parse.trace 文件转换为可读格式,并想在控制台上打印泄漏/CPU 使用情况。 I am using below xctrace command line to automate leaks/Time Profiling with Xcode 12 Instruments tool:
我正在使用下面的 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"
Is would be really great if someone can help.如果有人可以提供帮助,那就太好了。
Trace file for reference: https://gofile.io/d/EpvOXa跟踪文件供参考: https://gofile.io/d/EpvOXa
I am not sure if I understood your problem correctly, but if I run your command, I received a an error message.我不确定我是否正确理解了您的问题,但是如果我运行您的命令,我会收到一条错误消息。 The CLI-tool gave me the following instructions:
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"]'
According to this, the parameter toc is missing the two dashes.据此,参数 toc 缺少两个破折号。 I hope that will fix it for you.
我希望这会为你解决这个问题。
Exporting leaks are not supported (yet)..不支持导出泄漏(还)..
To quote Kacper from apple on the forums https://developer.apple.com/forums/thread/661295 :在论坛https://developer.apple.com/forums/thread/661295上引用 apple 的 Kacper:
Export feature doesn't support our Leaks and Allocations Instruments yet, as they're build as a different recording technology.
导出功能尚不支持我们的 Leaks 和 Allocations Instruments,因为它们是作为一种不同的记录技术构建的。 We're tracking it internally and will inform when this feature will be available in the release notes.
我们正在内部跟踪它,并会在发行说明中通知此功能何时可用。
However you could use the leaks tool in /usr/bin/leaks
to do just that!但是,您可以使用
/usr/bin/leaks
中的泄漏工具来做到这一点!
Execute $ leaks <pid>
to get an overview of all blocks of allocated memory that are no longer referenced.执行
$ leaks <pid>
以获得不再引用的已分配 memory 的所有块的概览。
You can also capture 2 memory graphs and compare them.您还可以捕获 2 memory 图表并进行比较。
# Capture memory graph
leaks --outputGraph=before.memgraph <pid>
# Diff current with previous graph
leaks --diffFrom=before.memgraph <pid>
See Finding Leaks: Using the leaks Tool for more information.有关详细信息,请参阅查找泄漏:使用泄漏工具。
leaks: Search through a process for leaked memory.
Usage: leaks [options] pid | partial-process-name | memory-graph-file
leaks [options] --atExit -- <command-and-arguments>
-e/--exclude <sym> exclude leaked blocks whose backtraces include the specified symbol
-h/--help show this helpful usage message!
-q/--quiet suppress the process description header and footer
--list print the leaks as a list ("classic"-style) rather than as a tree
--groupByType in leak trees, group children by type rather than showing individual instances
(for normal leak detection output, and --referenceTree, --dominatorTree, and --autoreleasePools modes)
--nostacks do not print backtraces or save them in the memory graph file, even when available
--fullStacks print backtraces with one line per frame
--nosources do not show sourceFile:lineNumber in backtraces
--outputGraph=<path> save a memory graph file into the given directory or file
--fullContent print or save full allocation content descriptions
(this is the default for printing output for live processes)
--readonlyContent print or save just readonly allocation content descriptions
(this is the default for saving memory graphs)
--noContent do not save or print any allocation content descriptions
--hex show the hex content of leaked allocations, if there is no description of content
--forkCorpse generate a corpse fork from process and run leaks on it
--diffFrom=<memgraph> show only the new leaks since the specified memgraph
--trace=<address> print chains of references from process 'roots' (e.g., global data) to the given block
--traceTree=<address> print a reverse tree of references, from the given block up to the process roots
--referenceTree print a reference tree of allocated memory starting at root nodes
--autoreleasePools print contents of autorelease pools, by thread
--debug=[mode] enable additional debugging modes; list available modes with --debug=help
--atExit launch the specified command and run leaks when that process exits.
This should be the last argument; use '--atExit -- <command-and-arguments>'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.