---
title: 低负载性能采集库
description: "libkperf是一个轻量级Linux性能采集库，它能够让开发者以API的方式执行性能采集，包括PMU采样和符号解析。libkperf把采集数据内存化，使开发者能够在内存中直接处理采集数据，避免了读写perf.data带来的开销。"
url: https://www.hikunpeng.com/document/detail/zh/nativedevp/twp/Kunpeng_Development_0081.html
sourcePath: /source/zh/nativedevp/twp/Kunpeng_Development_0081.html
indexId: 2ccb0e859e08992481c7fe84b7b7119165b58fcc953ddce3db7add913feb9fa055
---
# 低负载性能采集库

#### 功能简介

libkperf是一个轻量级Linux性能采集库，它能够让开发者以API的方式执行性能采集，包括PMU采样和符号解析。libkperf把采集数据内存化，使开发者能够在内存中直接处理采集数据，避免了读写perf.data带来的开销。


#### 环境要求

支持的CPU架构：鲲鹏

支持的OS：- openEuler
- OpenCloudOS
- TencentOS
- KylinOS
- CentOS


#### 编译要求

- 最低依赖GCC版本：GCC 4.8.5和glibc 2.17
- 最低依赖Python版本：Python 3.7

如果编译报错提示没有numa.h文件，需要先安装对应的numactl-devel包。

如果编译链接在Found PythonInterp报CMake错误，需要先安装所需的python3-devel包。


编译生成动态库和C的API：

```
git clone --recurse-submodules https://gitee.com/openeuler/libkperf.git
cd libkperf
bash build.sh install_path=/path/to/install
```

如果想要编译调试版本：

```
bash build.sh install_path=/path/to/install buildType=debug
```

如果想要编译Python包：

```
bash build.sh install_path=/path/to/install python=true
```

安装后若需要卸载Python库，可以执行以下命令:

```
python3 -m pip uninstall -y libkperf
```


#### 文档

- 详细文档可参考：  详细使用文档(https://atomgit.com/openeuler/libkperf/blob/master/docs/Details_Usage.md)

- Python API文档可参考：  Python API说明文档(https://atomgit.com/openeuler/libkperf/blob/master/docs/Python_API.md)
