首页 技术 正文
技术 2022年11月16日
0 收藏 837 点赞 3,413 浏览 1927 个字

profile是用于追踪程序执行调用流程的工具,类似于perf中的-g指令

相比perf -g而言,profile功能化更加细分,可以根据需要选择追踪层面,例如-U(用户要调用流程) -K (内核态调用流程)

下面具体介绍该工具的使用

采用profile –help,我们可以看到如下介绍:

usage: profile [-h] [-p PID] [-U | -K] [-F FREQUENCY | -c COUNT] [-d] [-a]
[-f] [--stack-storage-size STACK_STORAGE_SIZE] [-C CPU]
[duration]Profile CPU stack traces at a timed intervalpositional arguments:
duration duration of trace, in seconds # profile的持续时间optional arguments:
-h, --help show this help message and exit
-p PID, --pid PID profile this PID only # 只追踪该pid的调用流程
-U, --user-stacks-only                   # 查看用户态函数调用流程
show stacks from user space only (no kernel space
stacks)
-K, --kernel-stacks-only                  # 只查看内核态调用流程
show stacks from kernel space only (no user space
stacks)
-F FREQUENCY, --frequency FREQUENCY # profile追踪采样频率 例如: -F 99 表示按照99hz的频率进行采样,默认是采用的49hz
sample frequency, Hertz
-c COUNT, --count COUNT                   # 选择采样次数 -c 5表示在周期内采样5次,-c和-F两者不能同时使用
sample period, number of events
-d, --delimited insert delimiter between kernel/user stacks # 在内核和用户态之间插入分界符 “---”
-a, --annotations add _[k] annotations to kernel frames # 在显示的内核函数后面标记 '[k]'标识
-f, --folded output folded format, one line per stack (for flame #采用横向线上模式 xxx;xxx_1;xxxxx_2
graphs)
--stack-storage-size STACK_STORAGE_SIZE                 # 设置调用栈的使用空间和默认支持空间大小
the number of unique stack traces that can be stored
and displayed (default )
-C CPU, --cpu CPU cpu number to run profile on           # 允许几个cpu运行profile程序     examples:
./profile # profile stack traces at Hertz until Ctrl-C
./profile -F # profile stack traces at Hertz
./profile -c # profile stack traces every in a million events
./profile # profile at Hertz for seconds only
./profile -f # output in folded format for flame graphs
./profile -p # only profile threads for PID
./profile -U # only show user space stacks (no kernel)
./profile -K # only show kernel space stacks (no user)

下面对相关重要指令进行测试分析:

    1. profile -f

      在没有添加-f参数时,可看出是一行线上一个函数调用信息

      bcc-tools工具之profile

      加入-f参数后,采用每行递增线上函数调用信息。bcc-tools工具之profile

    2. profile -d  :用于将内核态和用户态函数通过”–“分割开来,如下图红色框框所示

bcc-tools工具之profile

      3.profile -F  :用于设置该工具采样频率

      bcc-tools工具之profile

      4. profile -K -a :用于仅显示内核调用函数,并且在函数后面增加”_[K]”标识 (156标识进程id号)

      bcc-tools工具之profile

      5. profile -c :在采样周期内对每一个线程xx个event进行采样

      bcc-tools工具之profile

<!–

–>

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,023
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,513
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,360
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,143
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,774
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,852