Re: System.arrayCopy Vs array clone



Daniel Pitts wrote:
On Feb 27, 12:52 pm, mei <m...@xxxxxx> wrote:
Hello,

I read in bloch's effective java that the only interesting use of
clone() is to copy array cheaply. On the web, I found opposite opinions:
Some people pretend that instantiate a new array, then call
System.arrayCopy is faster.
I made a quick bench that seems to confirm this second hypothesis.
However, with all the respect I have for the author, I wished all the
same to ask the question on this newsgroup. Is there something I and a
few other people from the Internet missed?
Thanks in advance,
Mei.

Its probably an "out of date" assertion.

No, it remains interesting. Notice that Bloch doesn't say "recommended" use.

There have been a number of threads here touching on the dangers of assuming performance characteristics in a Java program, especially between versions.
Algorithmic characteristics of a benchmark and execution profiles from its testbed both influence the outcome.

Since you actually measured the performance you have some facts about System.arrayCopy(). Would you be willing to share your benchmark code and how you ran it?

- Lew
.