Mail Archives: djgpp/1997/07/15/02:32:06
Alan Poppleton wrote:
>
> I have allocated two memory blocks with the malloc function. What is
> the fastest method of copying from one to the other? Would assembler
> help? If so what is the code? I am currently using memcpy to copy but I
> need to be as fast as possible. Also is there are faster method of
> setting a chunk of memory to a certain value than the memset function.
With optimizations on ('-O' switch or its variants '-O1', '-O2', '-O3',
etc.), memset() and memcpy() should compile to very efficient code. If
you doubt this, try using the '-S' switch to generate assembly code, and
read it to see what the compiler produced. The '-m486' option might
produce faster code on 486 computers as well.
If you're using a Pentium, then you may want to do some assembly coding
to get optimal speed, or try downloading PGCC, a version of gcc that
incorporates Pentium optimizations. Visit
<http://www.delorie.com/djgpp/> to get the URL - it's right at the top
of the page.
--
---------------------------------------------------------------------
| John M. Aldrich | "Always listen to experts. They'll |
| aka Fighteer I | tell you what can't be done, and why.|
| mailto:fighteer AT cs DOT com | Then do it." |
| http://www.cs.com/fighteer | - Lazarus Long |
---------------------------------------------------------------------
- Raw text -