天天看點

ABAP動态程式設計的性能開銷 - Overhead of ABAP dynamic programming

In Mytask offline performance improvement, it is necessary to support both two DDIC structure modelled in BP and Task, that is, crmt_odata_attachment_t and crmt_bp_odata_attachment_t. It is unknown which data type will be used since they are determined by runtime according to different urls passed from frontend.

The first approach to support both structure is first trying with my task structure using line ASSIGN lr_ref->* TO CASTING. If this line fails, we can know the structure does not belong to Task model, so we can use BP structure to store result.

In this approach, we have defined two variables with separate field symbol with data type crmt_odata_attachment_t and crmt_bp_odata_attachment_t to hold result.

ABAP動态程式設計的性能開銷 - Overhead of ABAP dynamic programming

In approach2, we use generic programming style, neither dedicated type for BP nor for Task is defined in the code. Instead, “ANY TABLE” is defined.

ABAP動态程式設計的性能開銷 - Overhead of ABAP dynamic programming

In ABAP help, it is said we should avoid generic programming unless it is really necessary from security and performance perspective. In this case, I would like to know the performance loss if I use approach2 compared with approach1.

Then I write the following report to get answer:

ABAP動态程式設計的性能開銷 - Overhead of ABAP dynamic programming

When handling with 10 tasks: performance difference: 300 microseconds

ABAP動态程式設計的性能開銷 - Overhead of ABAP dynamic programming

100 tasks: approach1 is one time faster than approach2

ABAP動态程式設計的性能開銷 - Overhead of ABAP dynamic programming

500 tasks:

ABAP動态程式設計的性能開銷 - Overhead of ABAP dynamic programming

1000 tasks:

ABAP動态程式設計的性能開銷 - Overhead of ABAP dynamic programming

10000 tasks:

ABAP動态程式設計的性能開銷 - Overhead of ABAP dynamic programming

繼續閱讀