File: fb_bench.h

package info (click to toggle)
golang-github-google-flatbuffers 24.12.23-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental, forky, sid, trixie
  • size: 17,704 kB
  • sloc: cpp: 53,217; python: 6,900; cs: 5,566; java: 4,370; php: 1,460; javascript: 1,061; xml: 1,016; sh: 886; makefile: 13
file content (23 lines) | stat: -rw-r--r-- 641 bytes parent folder | download | duplicates (13)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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_