当前位置:网站首页>perf 性能调试
perf 性能调试
2022-07-25 11:55:00 【mightbxg】
perf 是 linux 系统调试工具之一,可以以一定采样频率 (默认 4000Hz) 监测指定进程中函数运行情况,从而分析程序的性能瓶颈,进而针对性优化。
工具安装
perf 并不是 linux 系统默认自带的,需要安装 linux-tools 工具集,比如:
sudo apt install linux-tools-common linux-tools-generic linux-tools-`uname -r`
或者自己从源码编译:
sudo apt install build-essential git flex bison
git clone --depth 1 https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
cd linux/tools/perf
make
sudo cp perf /usr/bin
如果你的系统内核自己升级过,那就只能从源码编译,因为 apt 源只有当前系统默认内核的 linux-tools-xxx
perf 使用方法
首先需要把被测试的程序跑起来,并获得其 PID,假设程序名为 my_awesome_app,则获取 PID 的命令为:
MY_PID=$(ps -ef | grep my_awesome_app | grep -v 'grep' | awk '{print $2}')
然后启动 perf 监测:
perf record -F 4000 -g -p $MY_PID -- sleep 80
其中 -F <freq> 指定采样频率,-g 表示记录函数调用栈,-p <PID> 指定被监测的 PID,-- sleep <secs> 指定监测时长,具体请查看 perf record --help
perf 监测后会在当前路径生成 perf.data 文件,执行 perf report -n --stdio 会读取 perf.data 并将结果展示在终端。
火焰图
perf report 分析性能还是很不方便,可以转换成火焰图来查看,工具地址:FlameGraph,具体使用方法仓库里已经写的很清楚了。
参考资料
边栏推荐
- 【四】布局视图和布局工具条使用
- Plus版SBOM:流水线物料清单PBOM
- Eureka使用记录
- Implement anti-theft chain through referer request header
- 推荐系统-协同过滤在Spark中的实现
- cmake 学习使用笔记(二)库的生成与使用
- 启牛开的证券账户安全吗?是怎么开账户的
- Table partition of MySQL
- 使用TensorBoard可视化训练过程
- R language Visual scatter diagram, geom using ggrep package_ text_ The rep function avoids overlapping labels between data points (set the min.segment.length parameter to inf and do not add label segm
猜你喜欢

Visualize the training process using tensorboard

水博士2

2.1.2 application of machine learning

Ups and downs of Apple's supply chain in the past decade: foreign head teachers and their Chinese students

Fault tolerant mechanism record
![SSTI 模板注入漏洞总结之[BJDCTF2020]Cookie is so stable](/img/19/0b943019fe1c959c4b79035a814410.png)
SSTI 模板注入漏洞总结之[BJDCTF2020]Cookie is so stable

After having a meal with trump, I wrote this article

Atomic atomic class

Dr. water 2

Pytorch advanced training skills
随机推荐
Monit installation and use
PyTorch项目实战—FashionMNIST时装分类
Technical management essay
Ansible
基于Caffe ResNet-50网络实现图片分类(仅推理)的实验复现
Create directories and subdirectories circularly
【C语言进阶】动态内存管理
PyTorch主要模块
Plus版SBOM:流水线物料清单PBOM
【11】 Production and adjustment of vector and grid data Legends
2022河南萌新联赛第(三)场:河南大学 I - 旅行
【三】DEM山体阴影效果
【10】 Scale bar addition and adjustment
想要做好软件测试,可以先了解AST、SCA和渗透测试
Mirror Grid
Jenkins configuration pipeline
【4】 Layout view and layout toolbar usage
Jenkins配置流水线
【Flutter -- 实例】案例一:基础组件 & 布局组件综合实例
[fluent -- example] case 1: comprehensive example of basic components and layout components