30 using std::unique_ptr;
38 template <
class CursClass>
40 CursClass
c(iobuf_benchmark.get());
49 runBenchmark<RWPrivateCursor>();
55 runBenchmark<RWUnshareCursor>();
61 Cursor c(iobuf_read_benchmark.get());
70 Cursor c(iobuf_read_benchmark.get());
81 Cursor c(iobuf_read_benchmark.get());
90 Cursor c(iobuf_read_benchmark.get());
100 Cursor c(iobuf_read_benchmark.get());
102 for (
int i = 0;
i <
size; ++
i) {
110 std::array<uint8_t, 4> actual;
111 if (c.
pullAtMost(actual.data(), actual.size()) != actual.size()) {
114 return memcmp(actual.data(), expected.data(), actual.size()) == 0;
122 return actual == expected;
128 constexpr std::array<uint8_t, 4>
prefix = {{0x01, 0x02, 0x03, 0x04}};
144 bool result =
prefix(c, 0x01020304);
167 gflags::ParseCommandLineFlags(&argc, &argv,
true);
static std::unique_ptr< IOBuf > create(std::size_t capacity)
constexpr detail::Map< Move > move
bool prefixBaseline(Cursor &c, const std::array< uint8_t, 4 > &expected)
size_t pullAtMost(void *buf, size_t len)
bool prefix(Cursor &c, uint32_t expected)
BENCHMARK_RELATIVE(prefix, iters)
constexpr auto size(C const &c) -> decltype(c.size())
size_t read(T &out, folly::io::Cursor &cursor)
unique_ptr< IOBuf > iobuf_read_benchmark
void prependChain(std::unique_ptr< IOBuf > &&iobuf)
BENCHMARK(fbFollyGlobalBenchmarkBaseline)
int main(int argc, char **argv)
Range< const unsigned char * > ByteRange
Formatter< false, Args... > format(StringPiece fmt, Args &&...args)
Range< const char * > StringPiece
void append(std::size_t amount)
auto doNotOptimizeAway(const T &datum) -> typename std::enable_if< !detail::DoNotOptimizeAwayNeedsIndirect< T >::value >::type
unique_ptr< IOBuf > iobuf_benchmark