1 #ifndef BENCHMARKS_CPP_FLATBUFFERS_FB_BENCH_H_ 2 #define BENCHMARKS_CPP_FLATBUFFERS_FB_BENCH_H_ 3 4 #include <cstdint> 5 #include <memory> 6 7 #include "benchmarks/cpp/bench.h" 8 #include "include/flatbuffers/flatbuffers.h" 9 10 struct StaticAllocator : public flatbuffers::Allocator { StaticAllocatorStaticAllocator11 explicit StaticAllocator(uint8_t *buffer) : buffer_(buffer) {} 12 allocateStaticAllocator13 uint8_t *allocate(size_t) override { return buffer_; } 14 deallocateStaticAllocator15 void deallocate(uint8_t *, size_t) override {} 16 17 uint8_t *buffer_; 18 }; 19 20 std::unique_ptr<Bench> NewFlatBuffersBench( 21 int64_t initial_size = 1024, flatbuffers::Allocator *allocator = nullptr); 22 23 #endif // BENCHMARKS_CPP_FLATBUFFERS_FB_BENCH_H_