Xcode Instruments之iprofiler

iprofiler是一个命令行工具,与Instruments的作用相同,可以用来采集app数据,采集的数据放在.dtps的文件里,并能用Instruments打开。iprofiler现支持下列功能:Activity MonitorAllocationsCountersEvent ProfilerLeaksSystem TraceTime Profiler。

下面列出几个iprofiler的简单用法示例,以后知道它们具体怎么用的时候再进行补充:

$iprofiler -timeprofiler -activitymonitor


引用原文的说明:This example collects data from all running processes for the current sampling duration set in Instruments using the Time Profiler and Activity Monitor instruments. 该命令会在当前目录下产生allprocs.dtps文件,在Instruments中打开该文件如下图。

Xcode Instruments之iprofiler_第1张图片


$iprofiler -T 8s -d /temp -o YourApp_perf -timeprofiler -a YourApp

-T表示要收集多长时间以内的数据,-d表示产生的文件存在哪个目录里,-o表示产生的文件的名字,-a表示你要收集信息的app名称

上面的命令就表示用Time Profiler对名称为YourApp的app采集8s时间的信息,产生的文件存在/temp/YourApp_perf.dtps


$iprofiler -T 2500ms -o YourApp_perf -leaks -activitymonitor -a 823

该命令表示用LeaksActivity Monitor对进程ID为823的进程采集2.5s的信息,产生的文件为当前目录下的YourApp_perf.dtps。(823是怎么获得的?)


$iprofiler -d /tmp -timeprofiler -allocations -a YourApp.app

该命令表示用Time Profiler和AllocationsYourApp.app采集信息,时间为默认时间(默认时间是多少?10s?),产生的文件存在/temp/allprocs.dtps


$iprofiler -T 15 -I 1000ms -window 2s -o YourApp_perf -timeprofiler -systemtrace /path/to/Your.app arg1

-I表示记录数据的间隔时间

该命令表示用Time Profiler和System Trace采集/path/to/路径下的Your.app,并带有arg1参数,采集时间为15s,但是只保存最后2s的数据,产生的文件存在当前目录下的YourApp_perf.dtps


官方文档里iprofiler提供的配置参数如下:

Command

Description

-l

Provides a list of all supported instruments.

-L

Provides a list of all supported instruments and a description of whateach template does.

-legacy

Executes the legacy Instruments command-line interface found in/usr/bin/instruments.

-T duration

Sets the length of time that data is collected for. If this option is not set,then data is collected for 10 seconds. Duration can be set to seconds (1sor 1), milliseconds (10m or 10ms), or microseconds (10u or 10us).

-I interval

Sets the frequency with which a measurement is taken during the sampletime. If this option is not specified, it uses the Instruments default intervaltime. The interval can be set to seconds (1s or 1), milliseconds (10m or10ms), or microseconds (10u or 10us).

-window period

Limits the performance measurement to the final period of theiprofilerrun. If this option is not specified, performance is measuredthroughout the entire run. The period can be set to seconds (1s or 1),milliseconds (10m or 10ms), or microseconds (10u or 10us).

Note:This option can be used only with the -timeprofilerand-systemtracetemplate options.

-d path -o basename

Specifies the destination path and the name used when saving thecollected data. If the path is not specified, the output is saved to thecurrent working directory. If the basename is not specified, the processname or process ID is used.

-instrument name

Designates the instrument that is to be run. Valid name options are-activitymonitor,-allocations,-counters,-eventprofiler,-leaks,-systemtrace, and-timeprofiler.

At least one template must be listed. You can run up to all seventemplates at once.

-kernelstacks

Backtraces only include kernel stacks when this option is used.

If neither -kernelstacksor-userandkernelstacksoptions arespecified, backtraces include user stacks only.

Command

Description

-userandkernelstacks

Backtraces include both kernel and user stacks.

If neither -kernelstacksor-userandkernelstacksoptions arespecified, backtraces include user stacks only.

-pmc PMC_MNEMONIC

Use this flag with -counters to specify the mnemonic of the event tocount. Multiple mnemonics should be comma-separated.

-allthreadstates

Causes the Time Profiler template to profile all threads. If this is notspecified, then Time Profiler profiles only running threads.

-a process/pid

Attaches to a process that is already running. Specifying a string willattach the process whose name starts with that string. Specifying aprocess ID attaches it to the process associated with that process ID.

The -leaksoption requires that a specific single process or process IDbe specified.

executable [args...]

Causes the target process to be launched for the duration of themeasurement. Lists the executable and the arguments as if they arebeing invoked from the command-line.



你可能感兴趣的:(开发)