Skip to content

Long runtime in Y_TEST_CODE_DETECTOR class #436

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ThomasErgin opened this issue Jul 22, 2021 · 2 comments · Fixed by #457
Closed

Long runtime in Y_TEST_CODE_DETECTOR class #436

ThomasErgin opened this issue Jul 22, 2021 · 2 comments · Fixed by #457
Assignees
Labels
bug Something isn't working correctly

Comments

@ThomasErgin
Copy link

Check Name

This issues applies the Test-Code-Detector-Class Y_TEST_CODE_DETECTOR which - I recon - is executed for every check.

Actual Behavior

Recently I scheduled a Code Pal check run on the report ZABAPGIT_STANDALONE, which is part of the open source project ABAPGIT and is a behemoth of ABAP (> 100.00 code lines!!!). I already expected that checking this report might take a while. But actually I found that check run to fail because of a too long runtime.

Strangly, during the execution I noticed, that a vast amount of runtime is spent on the test-code-detector, which - I guess - is intended to identify ABAPunit test classes. I performed a SAT trace on the Code Pal and found, that >95% of runtime is lost inside of Y_TEST_CODE_DETECTOR.
When checking the Call Stack I found, that in method Y_CHECK_BOOLEAN_INPUT_PARAM->EXECUTE_CHECK( ) a LOOP on all the class statements is carried out.
Later in the callstack I found, that in method Y_TEST_CODE_DETECTOR->DETERMINE_TEST_CODE the same LOOP on all class statements is repeated.
Both LOOPs combined will lead to a quadratic number of execution of the underlying process_tokens( )-method and - for this behemoth of ABAP - will lead to an unrealistic high runtime.

Without fully understanding the motivation of the developer, it appears to be wrong, that the process_tokens( )-method is called <number_of_class_statements>^2 times.

You can replicate this issue by schedule a check run on the ABAPGit-Standalone class. I suppose, that other bigger ABAPs will also be affected.

Expected Behavior

The runtime for bigger option of ABAP gets acceptable.

@ThomasErgin ThomasErgin added the bug Something isn't working correctly label Jul 22, 2021
@lucasborin
Copy link
Member

image

@lucasborin lucasborin self-assigned this Sep 10, 2021
@lucasborin lucasborin linked a pull request Sep 10, 2021 that will close this issue
@lucasborin
Copy link
Member

@ThomasKempfle: Solution available under branch 1.16.0. Feel free to pull and test it. By the way, it depends on SAP Note 2527903.

@lucasborin lucasborin mentioned this issue Nov 1, 2021
lucasborin added a commit that referenced this issue Nov 1, 2021
2021-11-01 v.1.16.0
------------------
* Prefer New: Dynamic Call with Parameters (#502)
* DB Access in UT: Global Inheritance (#500)
* DB Access in UT: Local Inheritance (#498)
* Skip 'Prefer RETURNING to EXPORTING' when both exist (#490)
* Pseudo Comment Usage: Multiple Inline Entries (#494)
* Prefer Pragmas to Pseudo Comments: Multiple Pseudo Comments (#489)
* Y_CHECK_MESSAGE_EASY_TO_FIND dump (#492)
* Chain Declaration for Complex Structures (#488)
* Empty Catch Alternative Pseudo Comment (#337)
+ Alternative Pseudo Comment (#486)
* line_exists does not support the operator IN (#484)
* Empty Catch: Test Double Framework (#483)
* Y_CHECK_FORM: Screen Events (#454)
* Magic Number: CASE SY-TABIX and CO NUMBERS (#480)
* Magic Number: Leading Zeros (#479)
* Prefer New to Create Object: Dynamic Type (#469)
* Magic Number: Table Index (#468)
* Use native *_wa variables (#474)
* Refactoring (#436,#452,#458)
* Cannot run unit tests on 752 (#461)
* Profiles: Allow Exemptions (#447)
* BAdI example class vs Percentage Comment (#443)
* Unit-Test Assert Validator (#450)
+ Prefer Pragmas to Pseudo Comments (#421)
+ COLLECT restriction (#441)
* RAP needs CREATE OBJECT ... FOR TESTING (#444)
* Filter functional operands in "Unit Test Assert" check (#460)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants