4 ms·
While I do enjoy this sort of analysis, I feel the decision to choose one method over another should be based on benchmarks (preferably with more than one size
by carlsonmark 9y ago
While I do enjoy this sort of analysis, I feel the decision to choose one method over another should be based on benchmarks (preferably with more than one size of string.) After benchmarking, then do an analysis of the assembly code.
Guessing about pipelining, memory access times, and the effect of generated code size is much less valuable than real measurements.
- a_t48 9y agoBeyond this, &ptr and &arr are different types! The signature for bogus(arr, &arr) is something like void bogus(const char* arg1, const char (*arg2)[12]) While they do point to the same data, it's pretty rare to actually want to declare a const char (*)[N] as a function argument - template magic code excepted, you don't gain much over a char * and it's not the same as a char** The two lines do different things, so of course they will generate different code. What do you know, the one that actually lets you do useful things is a few bytes longer.