On Thursday, 28 May 2015 at 21:23:11 UTC, Momo wrote:
I'm currently investigating the difference of speed between references and copies. And it seems that copies got a immense slowdown if they reach a size of >= 20 bytes.

This is processor-specific, on different models of CPUs you might get different results. Here's what I see running your program with 4 and 5 ints in the struct:

C:\prog\D>dmd copyref.d -ofcopyref.exe -release -O -inline
16u

C:\prog\D>copyref.exe
by ref: 18
by copy: 85
by move: 84

C:\prog\D>copyref.exe
by ref: 18
by copy: 72
by move: 72

C:\prog\D>copyref.exe
by ref: 16
by copy: 72
by move: 72

C:\prog\D>dmd copyref.d -ofcopyref.exe -release -O -inline
20u

C:\prog\D>copyref.exe
by ref: 23
by copy: 98
by move: 91

C:\prog\D>copyref.exe
by ref: 20
by copy: 91
by move: 102

C:\prog\D>copyref.exe
by ref: 23
by copy: 91
by move: 91

I see these digits on an old Core 2 Quad and very similar on a Core i3. So your findings are not reproducible.

Reply via email to