If the types of the specified array and target array are the same, 1 billion copies are performed,
The consumed time is as follows:
CodeThe core test is as follows:
Int [] ints = {1534,233,332,423,524,324 6, 4357,734,567, 43,342 54, 325,332 5, 2423,345,575,235, 1,342, 1, 6, 54645,543 2, 5 }; int [] DEST = new int [ints. length]; array. copy (ints, DEST, ints. length); array. constrainedcopy (ints, 0, DEST, 0, ints. length); buffer. blockcopy (ints, 0, DEST, 0, ints. length * 4 );
Annotation analysis:
1, array. in the CLR processing mechanism, copy is the most flexible, powerful, boxed, and case-free, and the CLR primitive type can be extended. The ifarmattable interface compatible conversion can be implemented through internal judgment, of course, this powerful method will inevitably cause certain performance losses.
2. array. constrainedcopy has strict requirements on replication. It can only be of the same type or the source array type is a derived element type of the target type. No packing, unboxing, and downward conversion are performed.
3. Buffer. blockcopy is essentially in bytes as the unit of replication. In terms of the processing advantages of the underlying Language C and C ++, the efficiency is also high.
Of course, if you do not have high performance requirements, copy is enough. After all, the three do not consume much time for thousands of copies. You can select a project based on your needs!