MCPcopy Create free account
hub / github.com/ceph/ceph / buffer_iterator

Function buffer_iterator

src/test/perf_local.cc:286–307  ·  view source on GitHub ↗

Measure the cost of creating an iterator and iterating over 10 chunks in a buffer.

Source from the content-addressed store, hash-verified

284// Measure the cost of creating an iterator and iterating over 10
285// chunks in a buffer.
286double buffer_iterator()
287{
288 bufferlist b;
289 const char s[] = "abcdefghijklmnopqrstuvwxyz";
290 bufferptr ptr(s, sizeof(s));
291 for (int i = 0; i < 5; i++) {
292 b.append(ptr, i, 5);
293 }
294 int count = 100000;
295 int sum = 0;
296 uint64_t start = Cycles::rdtsc();
297 for (int i = 0; i < count; i++) {
298 auto it = b.cbegin();
299 while (!it.end()) {
300 sum += (static_cast<const char*>(it.get_current_ptr().c_str()))[it.get_remaining()-1];
301 ++it;
302 }
303 }
304 uint64_t stop = Cycles::rdtsc();
305 discard(&sum);
306 return Cycles::to_seconds(stop - start)/count;
307}
308
309// Implements the CondPingPong test.
310class CondPingPong {

Callers

nothing calls this directly

Calls 7

to_secondsFunction · 0.85
get_current_ptrMethod · 0.80
discardFunction · 0.70
appendMethod · 0.45
cbeginMethod · 0.45
endMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected