4 ms·
The simplest way to make quick experiments for me is with https://godbolt.org/ https://godbolt.org/ . For my particular example: https://godbolt.org/z/8GvYzYj5
by adrian17 4y ago
The simplest way to make quick experiments for me is with https://godbolt.org/ https://godbolt.org/ .
For my particular example: https://godbolt.org/z/8GvYzYj5h https://godbolt.org/z/8GvYzYj5h
You can see we're trying to put a 1kB object on heap, but the compiler generates two `memcpy` calls - first to copy it on stack to build the wrapper struct, second to actually copy the entire struct onto allocated memory.
In "real programs", you just need to look at the program's assembly. Or even more generally, I originally noticed this when observing the unusually high amount of time spent in some functions when profiling.