mirror of
https://github.com/scylladb/scylladb.git
synced 2026-04-22 17:40:34 +00:00
Seastar is an external library from Scylla's point of view so we should use the angle bracket #include style. Most of the source follows this, this patch fixes a few stragglers. Also fix cases of #include which reached out to seastar's directory tree directly, via #include "seastar/include/sesatar/..." to just refer to <seastar/...>. Closes #10433
61 lines
1.6 KiB
C++
61 lines
1.6 KiB
C++
/*
|
|
* Copyright (C) 2019-present ScyllaDB
|
|
*/
|
|
|
|
/*
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
*/
|
|
|
|
#include <seastar/testing/perf_tests.hh>
|
|
#include <seastar/testing/test_runner.hh>
|
|
|
|
#include <random>
|
|
|
|
#include "vint-serialization.hh"
|
|
|
|
class vint {
|
|
public:
|
|
static constexpr size_t count = 1000;
|
|
private:
|
|
std::vector<uint64_t> _integers;
|
|
bytes _serialized;
|
|
public:
|
|
vint()
|
|
: _integers(count)
|
|
, _serialized(bytes::initialized_later{}, count * max_vint_length)
|
|
{
|
|
auto eng = seastar::testing::local_random_engine;
|
|
auto dist = std::uniform_int_distribution<uint64_t>{};
|
|
std::generate_n(_integers.begin(), count, [&] { return dist(eng); });
|
|
|
|
auto dst = _serialized.data();
|
|
for (auto v : _integers) {
|
|
auto len = unsigned_vint::serialize(v, dst);
|
|
dst += len;
|
|
}
|
|
}
|
|
|
|
const std::vector<uint64_t>& integers() const { return _integers; }
|
|
bytes_view serialized() const { return bytes_view(_serialized.data()); }
|
|
};
|
|
|
|
PERF_TEST_F(vint, serialize) {
|
|
std::array<int8_t, max_vint_length> output;
|
|
auto dst = output.data();
|
|
for (auto v : integers()) {
|
|
perf_tests::do_not_optimize(unsigned_vint::serialize(v, dst));
|
|
perf_tests::do_not_optimize(dst);
|
|
}
|
|
return count;
|
|
}
|
|
|
|
PERF_TEST_F(vint, deserialize) {
|
|
auto src = serialized();
|
|
for (auto i = 0u; i < count; i++) {
|
|
auto len = unsigned_vint::serialized_size_from_first_byte(src.front());
|
|
perf_tests::do_not_optimize(unsigned_vint::deserialize(src));
|
|
src.remove_prefix(len);
|
|
}
|
|
return count;
|
|
}
|