---
title: 资源监测类
description: "为方便用户查询TA的CPU和内存等资源使用率，提供了相关接口供用户调用。"
url: https://www.hikunpeng.com/document/detail/zh/kunpengcctrustzone/cca/devg/Kunpeng_ommercialcryptography_16_0023.html
sourcePath: /source/zh/kunpengcctrustzone/cca/devg/Kunpeng_ommercialcryptography_16_0023.html
indexId: b0f1dba86c55502772049b7cdccf10bb03df4a11c112b8161242025cd7c66f5c81
---
# 资源监测类

为方便用户查询TA的CPU和内存等资源使用率，提供了相关接口供用户调用。

- 获取CPU占用率。

```
int SDF_GetCpuUsage(void *hSessionHandle, double *pdCpuUsage);
```


**表1 参数说明**

| 参数 | 描述 |
| --- | --- |
| hDeviceHandle[in] | 已打开的设备句柄 |
| pdCpuUsage[out] | CPU占用率 |


**表2 返回值说明**

| 返回值 | 说明 |
| --- | --- |
| 0 | 成功 |
| 非0 | 失败，返回错误码 |


  1. 该接口以进程粒度统计TA应用CPU使用率。 2. TA应用每一个业务线程将被绑定在设定的CPU所有核心上，考虑性能调优和资源利用，建议设置业务线程数等于绑定CPU核心数。 3. 计划绑定的CPU核心可在相关配置文件中设置。


- 获取内存使用率。

```
int SDF_GetMemUsage(void *hSessionHandle, double *pdMemUsage);
```


**表3 参数说明**

| 参数 | 描述 |
| --- | --- |
| hDeviceHandle[in] | 已打开的设备句柄 |
| pdMemUsage[out] | 内存使用率 |


**表4 返回值说明**

| 返回值 | 说明 |
| --- | --- |
| 0 | 成功 |
| 非0 | 失败，返回错误码 |
