Re:Orthodox C++
by asddubs on Monday December 28, 2020 @03:25AM
(#25557635)
I don't think it really contradicts what I said, I didn't say extra instructions were executed on each function call, just generated. I guess it depends on how you define overhead, but if you compile a program that does not use exceptions with exceptions on, it will run slower if you benchmark it. That being said, I do use exceptions and think they're obviously worth it, but there is an overhead to them, even if it's not as simple as "x additional instructions are executed"
[ Parent
| on HN ]
That would be one strange benchmark then. It would have to be benchmarking something other than the code in question.
Simple analogy: let's say you have a program that has 10 functions in it. You write a benchmark that exercises one of these and never (no, not once, never) calls the other functions. The other 9 are truly dead code. Would you expect the benchmark result to be different between that and a program that only included the one function being benchmarked?
yes if the generated code causes e.g. more cache misses and branch mispredictions, which additional instructions inbetween the executed ones will