On 2007-11-10 01:24:26 -0800, "Cor Ligthert[MVP]"
<no************@planet.nlsaid:
In my opinion is this often investigated, why don't you do that
yourself or search these newsgroups (it can be that it was in the
languages.vb newsgroup).
I have. But what happens when my own investigations disagree with
someone's claims? Should I not give them an opportunity to explain
themselves?
(It is partially just joking reflecting your answer to Linuxfedora,
what Mattias wrote is well knowed, I was searched this answer in my
mind and Mattias answer was reminding it to me.)
It appears to me that what "is well knowed [sic]" is frequently wrong.
And it appears to be so in this case as well. I did in fact write some
test code, and there is practically no difference at all between using
Array.Copy() and Buffer.BlockCopy(). In fact, in my tests Array.Copy()
came out slightly faster when copying within an array (and slightly
slower copying from one array to another).
The performance differences were in roughly the same ballpark as those
that exist simply because of the multi-tasking environment (i.e. the
resulting times for each test varied nearly as much from one execution
of a test to the next, as they do between the specific alternative
algorithms being tested). The largest difference I was able to
reproduce was a mere 5%, hardly consequential even if _all_ that the
code does is copy arrays, and a completely trivial difference for any
code that does anything else that's at all interesting.
It's frustrating to me to see so many people just blindy repeat
"conventional wisdom", things that they have "researched" (as you have
here) only by searching other posts in the newsgroups. As some wise
people in my life have always told me, "believe nothing you read, and
only half of what you see". A bit hyperbolic, but there's a very large
grain of truth in that statement.
So, the question still stands: does anyone have any _concrete_,
firsthand information that would suggest that using Buffer.BlockCopy()
in this situation is in fact a superior choice, considering the
tradeoffs involved?
Pete