Measure the cost of creating an iterator and iterating over 10 chunks in a buffer.
| 284 | // Measure the cost of creating an iterator and iterating over 10 |
| 285 | // chunks in a buffer. |
| 286 | double 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. |
| 310 | class CondPingPong { |
nothing calls this directly
no test coverage detected