---
title: 采集msproftx数据
description: "当用户需要定位应用程序或上层框架程序的性能瓶颈时，可通过特定接口，记录应用程序执行期间特定事件发生的时间跨度，写入性能数据文件。"
url: https://www.hiascend.com/document/detail/zh/canncommercial/latest/devaids/Profiling/atlasprofiling_16_0015.html
sourcePath: /source/zh/canncommercial/900/devaids/Profiling/atlasprofiling_16_0015.html
indexId: 5db63cb60933c3814e48215a5ee42cdd4ca535f4ad3b4a335c031ea65c605c3f75
---
# 采集msproftx数据

当用户需要定位应用程序或上层框架程序的性能瓶颈时，可通过特定接口，记录应用程序执行期间特定事件发生的时间跨度，写入性能数据文件。

可使用mstx API或msproftx API进行性能数据采集，两者二选一，推荐使用mstx API。

#### 前提条件

在用户程序代码内调用mstx API或msproftx API，记录应用程序执行期间特定事件发生的时间跨度。


#### 命令格式

登录运行环境，执行如下命令。

```
msprof [options] <app>
或msprof [options] --application=<app>
```

采集mstx数据必须传入用户程序，app参数说明请参见app参数说明，options参数说明请参见参数说明。


#### 参数说明

- --msproftx：必选，控制msproftx用户应用程序和上层框架输出性能数据的开关，可选on或off，默认值为off。
- --mstx-domain-include：可选，输出需要的domain数据。用户程序调用前缀为“mstxDomain”的接口，指定domain进行打点时，可选择只输出本参数配置的domain数据。
  开关内容填写mstxDomainCreateA接口的“name”。可指定多个domain，使用逗号隔开，default表示默认domain。需配置--msproftx=on。

  与--mstx-domain-exclude参数互斥，不可同时配置。和--mstx-domain-exclude参数都不配置时，会采集所有domain数据。若配置了程序中不存在的domain，则采集结果无该数据。

- --mstx-domain-exclude：可选，过滤不需要的domain数据。用户程序调用前缀为“mstxDomain”的接口，指定domain进行打点时，可选择不输出本参数配置的domain数据。
  开关内容填写mstxDomainCreateA接口的“name”。可指定多个domain，使用逗号隔开，default表示默认domain。需配置--msproftx=on。

  与--mstx-domain-include参数互斥，不可同时配置。和--mstx-domain-include参数都不配置时，会采集所有domain数据。


#### 使用示例

登录运行环境，在任意路径下执行以下命令：
```
msprof --msproftx=on
/home/projects/MyApp/out/main
```


在--output指定的目录下生成PROF_XXX目录，存放自动解析后的性能数据，相关结果文件请参见msproftx数据说明和db文件的MSTX_EVENTS表。
