-
Notifications
You must be signed in to change notification settings - Fork 48
Need precisions about JAVA S53 rule #176
Comments
I don't know where this rule comes from but it's for sure not part of the Android-specific plugin |
I think this rule has to do with Java performance with Collections. As i know, Foreach and Stream API is convenient to work with Collections. |
Hi @oussamaLaribi , I think @durandx would like to have an evidence to confirm what you said. I agree with @durandx. If we don't have a paper, it would b great to do benchmark test to check it (for example with JMH framework for example) |
Hello @dedece35, I have made a benchmark to test the example in the description of the rule. Here’s the code and the result. I'm kinda surprised.
|
Hi @oussamaLaribi , ok. good for micro-benchmark with JMH ! Another idea, is to benchmark other kind of loops. For example, to benchmark a stream, or standard for loop with simple index. |
Hi @dedece35, |
Thank you @oussamaLaribi for the benchmark. So if I understand correctly, looping from an Array is quicker than from a List, the exact opposite that said by the S53 rule ! To be sure, I made some more tests with JMH. I added a test where the With a big list (1_000_000 items) :
With a small list (10 items) :
With these tests I constantly have better performance on arrays... |
Hi,
I don't understand the recommandation concerning the rule cnumr-java:S53 (https://github.com/cnumr/ecoCode/blob/main/src/java-plugin/src/main/java/fr/cnumr/java/checks/UseCorrectForLoop.java)
Is it possible to access to the research paper regarding this rule (benchmark, java byte code analysis ...) ?
What are the experimental conditions ? Does the tests have been run on Android only, or does the tests have been on a server on Linux ?
The text was updated successfully, but these errors were encountered: