ABAP传值和传引用的性能比较 - pass by value VS pass by reference

简介: When I was doing MyTask offline performance optimization, I hesitated about whether to use pass by value or pass by reference.Pass by value pattern using RETURNING keyword:

lt_result = get_XXX().

Pass by reference pattern using IMPORTING keyword:


get_XXX( importing et_result = lt_result ).

I know that in theory, passing by reference has better performance than passing by value, since in former case, method of passing data from actual parameters to formal parameters when the proecdure is called. It is defined in the parameter interface of a procedure. In pass by reference, no local data object is specified for the actual parameter. Instead, the procedure receives a reference to the actual parameter during the call, and works with the actual parameter itself.

However, since the advantage of passing by value is I can type fewer characters which is appealing for a lazy programmer, I tend to choose passing by value if the performance difference between the two is trivial.


As a result I built a test case for performance comparison:

image.png

test result

for data volume with 1000 records, performance difference is 0.4 millisecond.


image.png

for data volume with 1 million records, performance difference is 0.2 seconds.

Base on this measurement, you can make decision accordingly. For my task optimization, since the magnitude of thousands makes more sense, so I choose passing by value finally.


Source code

See this method in AG3 for reference.


image.png

相关文章
|
5月前
|
Java C#
ABAP 7.40 新语法介绍系列之三 - ABAP Value 操作符试读版
ABAP 7.40 新语法介绍系列之三 - ABAP Value 操作符试读版
|
5月前
|
SQL 监控 Oracle
SAP ABAP 系统错误 Return value of the database layer SQL dbsl rc 99
SAP ABAP 系统错误 Return value of the database layer SQL dbsl rc 99
|
5月前
|
搜索推荐 数据安全/隐私保护
SAP ABAP RZ11 事务码里 Instance Profile 和 Current Value 等参数值的解读
SAP ABAP RZ11 事务码里 Instance Profile 和 Current Value 等参数值的解读
|
12月前
|
大数据 测试技术
关于 ABAP 函数调用 Pass by value 和 Pass by reference 的性能比较
关于 ABAP 函数调用 Pass by value 和 Pass by reference 的性能比较
|
12月前
|
BI
如何把 SAP ABAP 字符串变量的值下载成本地文件,以及文件路径 F4 Value Help 的实现方式试读版
如何把 SAP ABAP 字符串变量的值下载成本地文件,以及文件路径 F4 Value Help 的实现方式试读版
|
Web App开发 测试技术 开发者
几种 SAP ABAP OData 服务的性能评估和测试工具介绍试读版
几种 SAP ABAP OData 服务的性能评估和测试工具介绍试读版
SAP ABAP 方法调用里传值(Pass Value)和传引用(Pass Reference)的区别试读版
SAP ABAP 方法调用里传值(Pass Value)和传引用(Pass Reference)的区别试读版
|
SQL 数据库
使用事务码 SAT 比较传统的 SELECT SQL 语句和 OPEN / FETCH CURSOR 分块读取 ABAP 数据库表两种方式的性能差异试读版
使用事务码 SAT 比较传统的 SELECT SQL 语句和 OPEN / FETCH CURSOR 分块读取 ABAP 数据库表两种方式的性能差异试读版
|
存储 JSON 搜索推荐
ABAP 报表中如何给报表的输入参数增添 F4 Value Help 试读版
ABAP 报表中如何给报表的输入参数增添 F4 Value Help 试读版

热门文章

最新文章

下一篇
无影云桌面