当前位置:网站首页>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,具体使用方法仓库里已经写的很清楚了。
参考资料
边栏推荐
- Feign use
- Pytorch advanced training skills
- Fault tolerant mechanism record
- WPF project introduction 1 - Design and development of simple login page
- Azure Devops(十四) 使用Azure的私有Nuget仓库
- Unexpected rollback exception analysis and transaction propagation strategy for nested transactions
- PyTorch主要模块
- [high concurrency] deeply analyze the execution process of worker threads in the thread pool through the source code
- 【十】比例尺添加以及调整
- Fiddler抓包APP
猜你喜欢

Pytorch advanced training skills
![[fluent -- example] case 1: comprehensive example of basic components and layout components](/img/d5/2392d9cb8550aa2692c8b41303d507.png)
[fluent -- example] case 1: comprehensive example of basic components and layout components

Eureka registration center opens password authentication - record

PyTorch进阶训练技巧

2022.07.24(LC_6125_相等行列对)
![[dark horse morning post] eBay announced its shutdown after 23 years of operation; Wei Lai throws an olive branch to Volkswagen CEO; Huawei's talented youth once gave up their annual salary of 3.6 mil](/img/d7/4671b5a74317a8f87ffd36be2b34e1.jpg)
[dark horse morning post] eBay announced its shutdown after 23 years of operation; Wei Lai throws an olive branch to Volkswagen CEO; Huawei's talented youth once gave up their annual salary of 3.6 mil

Communication bus protocol I: UART
![SSTI 模板注入漏洞总结之[BJDCTF2020]Cookie is so stable](/img/19/0b943019fe1c959c4b79035a814410.png)
SSTI 模板注入漏洞总结之[BJDCTF2020]Cookie is so stable

通过Referer请求头实现防盗链

Experimental reproduction of image classification (reasoning only) based on caffe resnet-50 network
随机推荐
Ansible
Plus版SBOM:流水线物料清单PBOM
Median (two point answer + two point search)
Spirng @Conditional 条件注解的使用
Implement anti-theft chain through referer request header
Technical management essay
想要做好软件测试,可以先了解AST、SCA和渗透测试
【4】 Layout view and layout toolbar usage
919. Complete binary tree inserter: simple BFS application problem
如何从远程访问 DMS数据库?IP地址是啥?用户名是啥?
From cloud native to intelligent, in-depth interpretation of the industry's first "best practice map of live video technology"
Kyligence 入选 Gartner 2022 数据管理技术成熟度曲线报告
Add a little surprise to life and be a prototype designer of creative life -- sharing with X contestants in the programming challenge
[dark horse morning post] eBay announced its shutdown after 23 years of operation; Wei Lai throws an olive branch to Volkswagen CEO; Huawei's talented youth once gave up their annual salary of 3.6 mil
PyTorch项目实战—FashionMNIST时装分类
阿里云技术专家秦隆:可靠性保障必备——云上如何进行混沌工程?
Pytorch main module
Musk's "eternal soul": half hype, half flicker
How to access DMS database remotely? What is the IP address? What is the user name?
2022.07.24(LC_6126_设计食物评分系统)