C++ exception throwing and catching are more costly than I realized. try{throw 123;} catch(int) {} costs 100 CPU clocks when run normally, 16,000 CPU clocks when run within a debugger, because of OS exception hooks and process switching mojo.
-
-
Replying to @TimSweeneyEpic
Throwing is meant to be the exceptional path: not throwing is very cheap. Throwing as normal control flow is a terrible idea. Arguable as to whether it's better than a proper return ok/error type.
2 replies 0 retweets 19 likes -
Replying to @herberticus @TimSweeneyEpic
You wrote the tweet I wanted to write
1 reply 0 retweets 4 likes
Replying to @redblobgames @herberticus
It’s a fine trade off, but even throwing shouldn’t have more cost than necessary given the demand that the no-throw case be free. In a lot of cases the cost is totally insane. Stepping through VC++ throws in a debugger reveals crazy OS entanglements.
11:54 AM - 6 Jan 2020
0 replies
0 retweets
2 likes
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.