Does code run faster in functions.php than in different theme templates?

It doesn’t matter. I know you think it matters, but it doesn’t. The reason it doesn’t matter has nothing to do with which one is actually faster. The speed of your website will NEVER be influenced by the placement of this function. Theoretically, sure, but in practice you’ll never see it. The only two places to spend time are the front end bandwidth and back end DB calls. That’s it. The front end will be too heavy, have too many http requests, errors, and a plethora of other front end issues. And the database is typically the biggest bottleneck on a website.

If you’re not spending time in these two areas, you’re wasting time.