Efficient C++: The hidden compile-time cost of auto return types
Efficient C++: The hidden compile-time cost of auto return types

Efficient C++: The hidden compile-time cost of auto return types

Efficient C++: The hidden compile-time cost of auto return types
Efficient C++: The hidden compile-time cost of auto return types
This is interesting, but drawing conclusions from only two measurements is not reasonable. Especially so when the time-span measured is in the order of a few ms. For example, the two instances of
clang
might not be running at the same clock frequency, which could easily explain away the observed difference.Plus, you could easily generate a very large number of functions, to increase the amount of work the compiler has to do. So I did just that (N = 10,000), using the function from the article, and used hyperfine to perform the actual benchmarking.
int
auto
So if you have a file with 10'000 simple functions with/without
auto
, then it increases your compile time by ~4%.I'd worry more about the readability of
auto
, than about the compile time cost at that point