3 ms·
For short strings, it basically doesn't help. For longer strings, it's a bit faster, it depends how bad what you were doing before was. Straight string compar
by DannyBee 10y ago
For short strings, it basically doesn't help.
For longer strings, it's a bit faster, it depends how bad what you were doing before was.
Straight string comparison is not a great application for this in part because it's to intel's advantage to make string compare loops work fast without it.
But you can be sure it speeds some customer's serious workload up significantly.
That said, it all depends.
It's great for "figure out if there is newline in the next 16 characters".
But again, compared to basic SSE compares, it often falls down for random string comparison.
See, e.g, https://www.strchr.com/strcmp_and_strlen_using_sse_4.2 https://www.strchr.com/strcmp_and_strlen_using_sse_4.2 which has timings on core i5.
it's of course, likely possible to find processors where it is faster/slower.
- pcwalton 10y agoEdit: I'm stupid and this comment was totally wrong; see below.
- DannyBee 10y agoFWIW: it actually does. i measured it in clang :) Why, i have no idea. My expectation would have been the same as yours (also, it's pcmp* and tzcnt)
- taeric 10y agoI think my biggest misunderstanding was thinking in terms of the size of strings that this compares. Seemed somewhat silly to think about comparing really small strings. Though, actually thinking about it, that makes a ton of sense. You rarely compare strings at the same level that you multiply a large matrix. That said, even the comparisons you were showing look like they would add up pretty fast.