r/cpp • • Oct 21 '25

When Compiler Optimizations Hurt Performance

https://nemanjatrifunovic.substack.com/p/when-compiler-optimizations-hurt
68 Upvotes

11 comments sorted by

View all comments

Show parent comment

7

u/Nicksaurus Oct 21 '25 edited Oct 21 '25

Lorem ipsum only contains ascii characters so I wanted to see how well it handles other code planes: https://quick-bench.com/q/b5FhDr7CxbZuhkSmzafUnQXyUI4

Turns out the result is pretty much the same. I think any real dataset is likely to work well with the branchy version because characters that are next to each other are likely to come from the same code planes

(The test strings came from here)

2

u/tialaramex Oct 21 '25

Also, real world text processed by machines is full of ASCII. Yes there is some Cyrillic, some Han characters, and some Emoji even, but even when you're processing text from a program used entirely by humans who don't know any languages written with the Latin writing system they're way more likely to use ASCII symbols than you might naively expect. They're almost certainly going to use ASCII's digits, and some of its other symbols for example.

2

u/Nicksaurus Oct 21 '25

Yes, the point is that it's a mixture, which is why branch prediction matters