Apply Optimize Java 8 Streams refactoring #786
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Apply Optimize Java 8 Streams Refactoring
Description
This is a semantics-preserving automated refactoring that attempts to optimize code using Java 8 streams when it is safe and possibly advantageous to do so. It may make certain streams parallel, others sequential, and unorder streams where necessarily. The tool does not add new functionality; it only rearranges existing code in an effort to increase its performance. Your program's results should be the same before and after the refactoring.
Details
Performance Evaluation
We did not find any dedicated performance tests in your repository. But, we did find many unit tests. We converted the unit tests involved in our transformation to performance tests by integrating the JMH framework. We also increased the dataset size, since unit tests are normally meant to be quick, to assess the increased parallelism. The results show an average speedup of ~3.92 (see below). Column avgt is the average run time in seconds per operation and the standard deviation is in parenthesis:
In most cases, we expanded the dataset to operation on 1,000,000 objects. FYI, you may find the patch we used to convert the unit tests to performance tests here. We had to move somethings around to make JMH work correctly (e.g., converting inner classes to outer ones). We also moved some of the setup code to its own method for profiling purposes.
Feedback
Thank you for your help in this evaluation! Any feedback you can provide would be very helpful. In particular, we are interested if each of the proposed changes are helpful or not.