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:
![](https://user-images.githubusercontent.com/5669954/59319440-41cbca80-8cfd-11e9-9a16-70cfdcce0bdb.png)
test result
for data volume with 1000 records, performance difference is 0.4 millisecond.
![](https://user-images.githubusercontent.com/5669954/59319442-41cbca80-8cfd-11e9-9889-b0b26d241640.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.
![](https://user-images.githubusercontent.com/5669954/59319445-42646100-8cfd-11e9-89e1-38a4283dc9d0.png)
![](https://user-images.githubusercontent.com/5669954/61616089-2a87e180-ac9a-11e9-861d-c29c2cf897af.png)
相关文章
- Vs Code报错vue/multi-word-component-names
- VS Code自定义修改选中内容和tab颜色
- 多通道振弦传感器无线采发仪VS-BOX 接口定义-传感器接口
- VS code配置C/C++开发环境
- Kubernetes on Bare Metal vs. Kubernetes on VMs:不仅仅是性能问题
- EMQX vs VerneMQ | 2023 MQTT Broker 对比
- VS开发在Linux上的体验(vs开发linux)
- 比较MySQL与VS的使用技巧(vs使用mysql)
- MySQL vs Oracle: 数据库管理的对比(mysql与oracle的区别)
- 比较:Visual Studio 与MySQL 链接(vs链接mysql)
- 微软发言人:我们希望把VS Code带到ARM平台的macOS上去
- 性能比较比较分析:VS编译器与Oracle数据库的性能差异(vs与oracle数据库)
- VS开发环境下MySQL教程简易指南(vs使用mysql教程)
- Cinnamon vs MATE vs Xfce:你应该选择那一个 Linux Mint 口味?
- 深入了解Oracle数据库备份策略:冷备份VS热备份(oracle冷备份热备份)
- VS一键连接MySQL,数据库管理如此便捷(vs连接mysql)
- VS如何进行远程调试Linux:详细指南(vs远程调试linux)
- VS连接SQL Server:让你从此走向数据库的新世界(vs连sqlserver)
- 提供安全服务【使用VS保障SQL Server安全性】(vs给sqlserver)
- VS整合SQLServer,实现数据库管理无忧(vs和sqlserver)
- 缓存 vs Redis不同的性能特征(缓存和redis的区别)
- 比较VS Code使用Redis管理数据(vs使用redis)
- VS开发环境再无Redis踪影(vs中没有redis了)
- Redis集群 vs 单机一场性能之争(redis集群与单机)
- Oracle与VS插件的竞技之战(oracle vs插件)