James Kuszmaul | 8e62b02 | 2022-03-22 09:33:25 -0700 | [diff] [blame] | 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 { |
| 11 | explicit StaticAllocator(uint8_t *buffer) : buffer_(buffer) {} |
| 12 | |
| 13 | uint8_t *allocate(size_t) override { return buffer_; } |
| 14 | |
| 15 | 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_ |