Skip to content

Commit af69879

Browse files
committed
test/perf: Add seastar::chunked_fifo<T*> scanning test
Here the fifo stores pointers to elements, to behave like array of pointers does, yet avoiding large (re)allocations on append. Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
1 parent 5916eb3 commit af69879

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tests/perf/container_perf.cc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <seastar/core/chunked_fifo.hh>
2828
#include <seastar/core/circular_buffer.hh>
2929
#include <seastar/util/split-list.hh>
30+
#include <seastar/core/chunked_fifo.hh>
3031
#include <seastar/testing/random.hh>
3132

3233
using trivial_elem = int;
@@ -262,6 +263,8 @@ class sum_perf {
262263
using split_list = seastar::internal::intrusive_split_list<element, 16, &element::sl_next>;
263264
split_list _split_list_16;
264265

266+
seastar::chunked_fifo<element*, 128> _chunked_fifo;
267+
265268
public:
266269
unsigned nr_elements = 1000;
267270

@@ -288,11 +291,13 @@ class sum_perf {
288291

289292
// Finally -- populate collections
290293
_array_of_pointers.reserve(nr_elements);
294+
_chunked_fifo.reserve(nr_elements);
291295
for (unsigned i = 0; i < nr_elements; i++) {
292296
element* e = &_elements[idx[i]];
293297
_array_of_pointers.push_back(e);
294298
_singly_linked_list.push_back(*e);
295299
_split_list_16.push_back(e);
300+
_chunked_fifo.push_back(e);
296301
}
297302
}
298303

@@ -327,6 +332,14 @@ class sum_perf {
327332
}
328333
return ret;
329334
}
335+
336+
uint64_t sum_fifo() const noexcept {
337+
uint64_t ret = 0;
338+
for (auto i = _chunked_fifo.begin(); i != _chunked_fifo.end(); i++) {
339+
ret += (*i)->value;
340+
}
341+
return ret;
342+
}
330343
};
331344

332345
PERF_TEST_F(sum_perf, sum_plain) {
@@ -352,3 +365,9 @@ PERF_TEST_F(sum_perf, sum_sl16) {
352365
perf_tests::do_not_optimize(value);
353366
return nr_elements;
354367
}
368+
369+
PERF_TEST_F(sum_perf, sum_fifo) {
370+
auto value = sum_fifo();
371+
perf_tests::do_not_optimize(value);
372+
return nr_elements;
373+
}

0 commit comments

Comments
 (0)