Oracle Solaris Studio 12.2:性能分析器

er_print 命令示例

本节提供一些使用 er_print 命令的示例。


示例 5–8 显示函数中时间花费情况的摘要


er_print -functions test.1.er


示例 5–9 显示调用方-被调用方关系


er_print -callers-callees test.1.er


示例 5–10 显示热点源代码行

源代码行信息假设代码已使用 -g 进行编译和链接。将尾随下划线附加到 Fortran 函数和例程的函数名称。函数名称后的 1 用于区分 myfunction 的多个实例。


er_print -source  myfunction 1 test.1.er


示例 5–11 从用户函数堆栈过滤名为 myfunc 的函数:


er_print -filters 'FNAME("myfunc") SOME IN USTACK' -functions test.1.er


示例 5–12 生成类似于 gprof 的输出

以下示例从实验生成一个类似 gprof 的列表。输出是一个名为 er_print.out 的文件,该文件列出前 100 个函数,后跟调用方-被调用方数据(按每个函数的归属用户时间排序)。


er_print -outfile  er_print.out -metrics e.%user -sort e.user \
-limit 100 -func -callers-callees test.1.er

也可以将此示例简化为以下独立的命令。但是请记住,在大型实验或应用程序中对 er_print 的每次调用可能需要花费很长时间。


er_print -metrics  e.%user -limit 100  -functions test.1.er

er_print -metrics  e.%user -callers-callees test.1.er


示例 5–13 仅显示编译器注释

无需运行程序即可使用此命令。


er_src -myfile.o


示例 5–14 使用挂钟分析来列出函数和调用方-被调用方


er_print -metrics  ei.%wall -functions test.1.er

er_print -metrics aei.%wall  -callers-callees test.1.er


示例 5–15 运行包含 er_print 命令的脚本


er_print -script myscriptfile test.1.er

myscriptfile 脚本包含 er_print 命令。脚本文件内容的样例如下:

## myscriptfile

## Send script output to standard output
outfile -

## Display descriptive information about the experiments
header

## Write out the sample data for all experiments
overview

## Write out execution statistics, aggregated over 
## the current sample set for all experiments
statistics

## List functions
functions

## Display status and names of available load objects
object_list


## Write out annotated disassembly code for systime, 
## to file disasm.out
outfile disasm.out
disasm systime


## Write out annotated source code for synprog.c 
## to file source.out
outfile source.out
source synprog.c

## Terminate processing of the script
quit