Replacing C's memcpy with a D implementation
rikki cattermole
rikki at cattermole.co.nz
Sun Jun 10 13:48:42 UTC 2018
On 11/06/2018 1:45 AM, Mike Franklin wrote:
> On Sunday, 10 June 2018 at 13:16:21 UTC, Adam D. Ruppe wrote:
>
>> arr1[] = arr2[]; // the compiler makes this memcpy, the optimzer can
>> further do its magic
>
> void memcpyD()
> {
> dst = src.dup;
malloc (for slice not static array)
> }
>
> void memcpyD2()
> {
> dst[] = src[];
memcpy
> }
>
> -----
> memcpyD: 1 ms, 725 μs, and 1 hnsec
> memcpyD2: 587 μs and 5 hnsecs
> memcpyASM: 119 μs and 5 hnsecs
>
> Still, the ASM version is much faster.
>
> btw, what's the difference between the two. If you can't tell, I'm
> actually not a very good D programmer.
>
> Mike
>
>
>
More information about the Digitalmars-d
mailing list