-
SAP Performance
浅析
本文来源于:
/tcsapbw/archives/
在
ABAP
开发中,
p>
Program
的
Performance
tunning
应该说是最基本也是最常见的工作内容,无论是
在新项目的开发、还是老项目的
maintainance
。同
时,关于
performance
,也是
ABAP
面试中几乎必
问的问题之一。在
performance
这方面,
SAP
< br>提供了专门的
BC490
课程以及相关跟进的
training
。
同
时,
Performance
以及程序优化乃至代码重构
(Refractory)
也是一项非常非常有技术含量的工作,自<
/p>
己也仅所知所学皮毛而已,还有相当相当多的知识需要加深入学习。
这里,修改了自己以前的一份总结,重新记录一下,以加深印象以防遗忘。
以下记录过程中,使用测试程序:
在这个程序中,人为多循环了
100
次。
最后执行结果:
1.
使
用
STAD
:
SAP
WorkLoad Business Transaction Analysis
Tcode: STAD.
使用该
T
code
得到
single program/transac
tion
运行时总体分析数据
(
查看用
户操作记录
)
。
其中,关于时间的概念:
其中,我们最经常用的是
Response Time, DB
time
以及
CPU time.
当
拿到一个结果分析数据后,可以按以下的方案进行初步地判断后续应继续
Trace
p>
何种结果。
|- CPU time >
40%(Response time - Dispatcher wait data)
==>Se30
:
Runtime Analysis
?
引起该结果的是由于一些
ABAP process
,例如
Loop
等
|- Database time > 40%(Response time -
Dispatcher wait data) ==>St05: SQL Trace
?
引起该结果的是由于大量的直接操作数据据等
其中,这里,很多时候,我们就是直接使用的
Response
Time
作为基数。
例如上面自己的
例程中,使用
STAD
可以得到如下的结果
(
注意
:
在进行筛选时系统时间方
面,一定是
Application
server
的时间,而非自己
presentaion
server
的时间
)
2.
使用
SE30: ABAP
Runtime Analysis
(
1
)
SE30
简介
Tcode: SE30.
使用该工具主要用于
Transaction
或
program
背后
ABAP
的运行时分析
,
比如分析哪步运行耗时最多,
并通过分析得出为什么、然
后进行代码优化。
使用
SE30
p>
主要分三步进行操作:
(1)
设定需要
Trace
的数据范围
决定将要分析哪些
object
哪些
data
哪些
process
等等
.
同时很重要的是,决定最后分析
结果的
“
粒度
”(Type of
aggregation: Full aggregation,
aggregation per calling position, no aggregaion).
这些是通过设置
SE30
运行时的
p>
variant
来实现的。
(2) Trace
跟踪
现在使用
SE30
可以直接从
< br>SE30
进入到所经
Trace
的
Transaction/Program
中
(
同一个
user session)
,也可以在另外
的
user session
中通过
menu
中的
a
ctive runtime analyze
等方法来
tra
ce
跟踪
.
(3)
分析结果
分析
SE30
的结果时,我们一般采取的是
“
渐进
”
的方式:先使用
full
aggregation
可以得到程序的主要的
FMs
或者逻辑
处理单元;然后再细化一下分析粒度,
aggregation per calling
position
,甚至
no aggregation
,这时就可以得到最详尽
的统计分析信息
:
table list, hierarchy
等等。
以下是
SE30
的初界面
:
其中关于
in
Parallet
session
中,再补充一下,平时也用到了
:
按纽
“Switch
on/off” of “In parallel session”
将会有一个
screen appears listing
all r/3 work processes running on the current
application server. To switch on
runtime analysis for the object,
选中它然
edit==>measurement==>switch
on/off
其中完成上面第一步的设置
,
< br>可以进去进行设置,这里不再赘述
;
这里仅记录一下
p>
aggregation
粒度的使
用,这也
是我们平时使用
SE30
最最基本的操作,因为设置它对我们<
/p>
analysis
实在是太重要了,深有
体会呀。
(
2
)使用
SE30
分析程序
分析上面自己的程序。
这里仅是一次简单记录,使用的
aggregation
level
是
no aggregation.
点击
execute
执行
:
程序会正常执行。最后返回到
SE30
:
这里,也可以使用
other file
去选择自己
trace
后的数据
(<
/p>
注意,关于这些结果文件的保存:如果保存在
当前的
Application
server
上的
file
system
里,那么最大到
8
天
时间
)
;点击
evalute:
好,从这张结果图上,我们可以得出非常重要的信息:
一目了然:本程序中
DB Time
消
耗掉绝大部分时间,达到
95%
以上。所以,主要问题出在了读
写数
据库上,后续优化需从这方面考虑
(
比如再进行
ST05
,然后寻找更佳解决方案
).
另外,注意,最上面那一排的
< br>button
提供了更为详细的分析工具,利如
tabl
e list, hit list,herarchy
等
等
(
但是注意,这是与在
variant
中设置的
aggregation level
相关的
)
。
A list of all called program parts or
instructions, sorted according to gross contains
one row for
each program
part,
包括
name of the program
part, gross time, net
time,
以及
number of times this
part
was called.
Group hit
list
A list of individual calls of
instructions grouped according to instruction
categories(
如
forms, FM,
methods)
,包括
gross
run time and the number of times the instruction
was called.
Table hit list
A
list showing accesses to DB
tables,
包括
access name, number
of accesses, table type,buffering
mode
以及一些其他信息
Hit list of
A list of all
internal table accesses that indicates the
internal name, the number of accesses, the
internal tables
gross and
net time taken(absolute value and percentage), the
memory required, and other info.
Call
hierarchy
A list showing the
chronological sequence of analyzed objects,
indicating the gross and net time
taken
and the call level.
Hit list
例如,我们上面的分析结果中,就看
hit list:
-
-
-
-
-
-
-
-
-
上一篇:(完整版)软件设计架构试卷
下一篇:个人防护用品的选择和使用