在Linux系统上搭建Android、Linux和Chrome性能监控和Trace分析的系统

perfetto是知名的Android系统性能分析平台。我们还可以用它去分析Linux系统和Chrome(需要装扩展)。本文我们只介绍如何安装的验证。

部署

我们使用Docker部署perfetto ui系统。

bash 复制代码
FROM ubuntu:20.04
WORKDIR /perfetto-ui
RUN apt-get update -y
RUN apt-get install -y git python3 curl gcc
RUN git clone https://android.googlesource.com/platform/external/perfetto/
RUN perfetto/tools/install-build-deps --ui
RUN perfetto/ui/build
EXPOSE 10000

然后使用下面代码打镜像包

bash 复制代码
docker build --pull --rm -f "Dockerfile" -t perfetto:latest "."

这个过程比较漫长。我这台24核CPU大概需要13分钟左右才能完成,特别在perfetto/ui/build环节,CPU会满负荷运行。

然后启动镜像

bash 复制代码
docker container run -d -p 10000:10000 --name perfetto-ui perfetto:latest

启动到服务可用大概需要1分钟左右。

验证

打开浏览器,输入本机地址(不是127.0.0.1)和映射的10000端口号,就能看到页面

Linux Trace

获取Trace

我们单开一台有管理员权限的Linux机器,然后按如下指令安装perfetto

bash 复制代码
sudo apt-get update -y
sudo apt-get install -y git python3 curl gcc
git clone https://android.googlesource.com/platform/external/perfetto/
perfetto/tools/install-build-deps --linux-arm
cd perfetto/
tools/gn gen --args='is_debug=false' out/linux
tools/ninja -C out/linux tracebox traced traced_probes perfetto

生成trace信息

bash 复制代码
sudo out/linux/tracebox -o trace_file.perfetto-trace --txt -c test/configs/scheduling.cfg

展现Trace

在刚才的网页中选择"Open trace file",然后选中刚产出的文件(可通过远程命令,比如sz导出到本地)

我们就看到Linux系统上各个CPU核心和各个进程的运行情况


参考资料

相关推荐
Javis2117 分钟前
【Linux高级全栈开发】2.1.3 http服务器的实现
linux·服务器·http
SunTecTec1 小时前
Linux grep -r 查找依赖包是否存在依赖类 Class
linux·运维·服务器
_龙小鱼_1 小时前
Kotlin扩展简化Android动画开发
android·开发语言·kotlin
Johny_Zhao1 小时前
AI+自动化测试系统方案:网络设备与网络应用智能测试
linux·网络·人工智能·python·网络安全·docker·ai·信息安全·云计算·ansible·shell·cisco·huawei·系统运维·itsm·华三·deepseek
Javis2111 小时前
【Linux高级全栈开发】2.1.2 事件驱动reactor的原理与实现
linux·运维·php
奔跑吧 android1 小时前
【android bluetooth 协议分析 01】【HCI 层介绍 6】【WriteLeHostSupport命令介绍】
android·bluetooth·bt·gd·aosp13·writelehostsup·hcicmd
FBI HackerHarry浩1 小时前
Linux云计算训练营笔记day10(MySQL数据库)
linux·运维·数据库·笔记·mysql
南暮思鸢2 小时前
vulnhub靶场——secarmy
linux·网络安全·vulnhub靶场·write up·secarmy
uwvwko2 小时前
ctfshow——web入门254~258
android·前端·web·ctf·反序列化
YOYO--小天2 小时前
RK3588 ADB使用
linux·嵌入式硬件·adb