Performance of copy algorithm
Matt Austern
austern@apple.com
Tue Feb 4 18:40:00 GMT 2003
On Monday, February 3, 2003, at 10:06 PM, Jerry Quinn wrote:
> A couple of observations. First, memcpy is very fast - the compiler
> doesn't have enough optimization to squeeze the same performance out
> of the straight loop. Second, we are taking a HUGE performance hit by
> using memmove for this case. I figured memmove might be about
> equivalent, but apparently not.
This is highly system dependent, and you don't say what OS you're
using for your test.
I know of one OS where memcpy is slower than a handwritten loop
(because memcpy on that system is stupid and always uses byte
instructions instead of word instructions), and I know of another OS
where memmove is very fast and memcpy is nothing but an alternate
name for it.
It's entirely possible that what you ought to be doing is improving
your OS's libc. memcpy and memmove ought to be carefully written
hand-optimized assembly code. Your tests might just show that on
your system nobody has given them the love and care that they
deserve.
--Matt
More information about the Libstdc++
mailing list