3 ms·
Two string on the stack are far more likely to be cached at a low cache level and/or prefetched (but probably already cached). A noticeable difference is much
by CyberDildonics 8y ago
Two string on the stack are far more likely to be cached at a low cache level and/or prefetched (but probably already cached).
A noticeable difference is much more likely to be because a string is too big and moved to the heap, which is in a different part of memory and thus not cached. Also there is the translation look aside buffer which caches the virtual memory to real memory address lookup. This also needs to be done on cold pages of memory and be expensive since it requires looking up in to the virtual memory table.