6 ms·
> In one setup, I used std::strings of length 64 and in the other I used 64 bit numbers. The main motivation behind measuring both numbers and strings was that
by dagenix 8y ago
> In one setup, I used std::strings of length 64 and in the other I used 64 bit numbers. The main motivation behind measuring both numbers and strings was that comparing 64 bit numbers takes a constant number of clock cycles
Pedantic: comparing 64 character strings is O(1).
- mattkrause 8y agoAn ironic complaint, given the domain name…
- AstralStorm 8y agoBut not constant clock cycles unless the strings fit in the cache page. Which they may. Use bigger strings if that is the case.
- kryptiskt 8y agoBut not a constant number of clock cycles. A comparison that fails on the first bytes can bail out early.
- colanderman 8y agoTo be fair, Intel's recent offerings include 512-bit registers [1]. I highly doubt std::string takes advantage of them. [1] https://en.wikipedia.org/wiki/AVX-512 https://en.wikipedia.org/wiki/AVX-512
- rurban 8y agoIt shouldn't because it slows down the whole core not to get too hot. 256 is the best size to use.
- dagenix 8y agoI accidentally chopped off the quote too early. The rest of it was: > (rather than comparing strings which requires O(n) cycles and memory reads)