mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-16 09:12:22 +00:00
Added Google benchmarks (and gtests) (#6920)
* Added Google benchmarks (and gtests) * Default building benchmarks to OFF as it requires c++11 * Separate benchmark CMakeLists.txt to its own file * Move output directory to target just flatbenchmark
This commit is contained in:
23
benchmarks/cpp/flatbuffers/fb_bench.h
Normal file
23
benchmarks/cpp/flatbuffers/fb_bench.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef BENCHMARKS_CPP_FLATBUFFERS_FB_BENCH_H_
|
||||
#define BENCHMARKS_CPP_FLATBUFFERS_FB_BENCH_H_
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
|
||||
#include "benchmarks/cpp/bench.h"
|
||||
#include "include/flatbuffers/flatbuffers.h"
|
||||
|
||||
struct StaticAllocator : public flatbuffers::Allocator {
|
||||
explicit StaticAllocator(uint8_t *buffer) : buffer_(buffer) {}
|
||||
|
||||
uint8_t *allocate(size_t) override { return buffer_; }
|
||||
|
||||
void deallocate(uint8_t *, size_t) override {}
|
||||
|
||||
uint8_t *buffer_;
|
||||
};
|
||||
|
||||
std::unique_ptr<Bench> NewFlatBuffersBench(
|
||||
int64_t initial_size = 1024, flatbuffers::Allocator *allocator = nullptr);
|
||||
|
||||
#endif // BENCHMARKS_CPP_FLATBUFFERS_FB_BENCH_H_
|
||||
Reference in New Issue
Block a user