| 183 | } |
| 184 | |
| 185 | void compareString(int len) { |
| 186 | // Just a simple test to figure out cost of reading a string |
| 187 | constexpr uint64_t kOps = 10'000'000; |
| 188 | constexpr uint64_t kObjects = 100'000; |
| 189 | std::vector<std::string> keys; |
| 190 | const std::string keyCopy(len, 'a'); |
| 191 | for (uint64_t i = 0; i < kObjects; i++) { |
| 192 | keys.push_back(keyCopy); |
| 193 | } |
| 194 | |
| 195 | std::mt19937 gen; |
| 196 | std::uniform_int_distribution<int> dist(0, kObjects - 1); |
| 197 | { |
| 198 | Timer t{folly::sformat("Read String - {: <3}", len), kOps}; |
| 199 | for (uint64_t i = 0; i < kOps; i++) { |
| 200 | // Read from the vector of strings (first memory load) |
| 201 | auto& k1 = keys[dist(gen)]; |
| 202 | auto& k2 = keys[dist(gen)]; |
| 203 | auto equal = bytesEqual(k1.data(), k2.data(), k1.size()); |
| 204 | folly::doNotOptimizeAway(equal); |
| 205 | } |
| 206 | } |
| 207 | } |
| 208 | |
| 209 | void callMallctl() { |
| 210 | constexpr uint64_t kOps = 10'000'000; |
no test coverage detected