Arrays of Wisdom of the Ancients
The Java Language and JDK Class Library have two distinct, yet connected, ways to group elements: arrays and Collections. There are pros and cons for using either one, so both are prevalent in real programs. To aid conversion between the two, there are standard methods to make a reference array appear as a Collection (e.g. Arrays.asList
), and to copy from Collection to array (e.g. several Collection.toArray
methods). In this post, we will try to answer a controversial question: which toArray
conversion pattern is faster?
The post uses JMH as the research crucible. If you haven't learned about it yet, and/or haven't looked through the JMH samples, I suggest you do that before reading the rest of this post for the best experience. Some x86 assembly knowledge is also helpful, though not strictly required.
Read full article from Arrays of Wisdom of the Ancients
No comments:
Post a Comment