MCPcopy Create free account
hub / github.com/facebook/CacheLib / compareString

Function compareString

cachelib/benchmarks/SmallOperationMicroBench.cpp:185–207  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

183}
184
185void 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
209void callMallctl() {
210 constexpr uint64_t kOps = 10'000'000;

Callers 1

mainFunction · 0.85

Calls 3

bytesEqualFunction · 0.85
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected