RTC Toolkit 5.0.0
Loading...
Searching...
No Matches
repositoryIfBench.hpp
Go to the documentation of this file.
1
13#ifndef RTCTK_COMPONENTFRAMEWORK_TEST_REPOSITORYIFV2BENCH_HPP
14#define RTCTK_COMPONENTFRAMEWORK_TEST_REPOSITORYIFV2BENCH_HPP
15
17
18#include <benchmark/benchmark.h>
19
21static std::shared_ptr<RepositoryIf> MakeRepository();
22}
23
24static void BM_WriteScalars(benchmark::State& state) {
25 using namespace rtctk::componentFramework;
26 using namespace rtctk::componentFramework::test;
27
28 auto repo = MakeRepository();
29 DataPointPath path{"foo"};
30 float value = 42.0;
31 repo->CreateDataPoint(path, value);
32
33 for (auto _ : state) {
34 repo->WriteDataPoint(path, value);
35 }
36
37 repo->DeleteDataPoint(path);
38}
39
40static void BM_ReadScalars(benchmark::State& state) {
41 using namespace rtctk::componentFramework;
42 using namespace rtctk::componentFramework::test;
43
44 auto repo = MakeRepository();
45 DataPointPath path{"foo"};
46 float value;
47 repo->CreateDataPoint(path, value);
48
49 for (auto _ : state) {
50 repo->ReadDataPoint(path, value);
51 }
52
53 repo->DeleteDataPoint(path);
54}
55
56static void BM_WriteVectors(benchmark::State& state) {
57 using namespace rtctk::componentFramework;
58 using namespace rtctk::componentFramework::test;
59
60 auto repo = MakeRepository();
61 DataPointPath path{"foo"};
62 std::vector<uint8_t> value(state.range());
63 repo->CreateDataPoint(path, value);
64
65 for (auto _ : state) {
66 repo->WriteDataPoint(path, value);
67 }
68
69 repo->DeleteDataPoint(path);
70}
71
72static void BM_ReadVectors(benchmark::State& state) {
73 using namespace rtctk::componentFramework;
74 using namespace rtctk::componentFramework::test;
75
76 auto repo = MakeRepository();
77 DataPointPath path{"foo"};
78 std::vector<uint8_t> value(state.range());
79 repo->CreateDataPoint(path, value);
80
81 for (auto _ : state) {
82 repo->ReadDataPoint(path, value);
83 }
84
85 repo->DeleteDataPoint(path);
86}
87
88BENCHMARK(BM_WriteScalars)
89 ->Iterations(100)
90 ->Repetitions(10)
91 ->ReportAggregatesOnly()
92 ->Unit(benchmark::kMillisecond);
93
94BENCHMARK(BM_ReadScalars)
95 ->Iterations(100)
96 ->Repetitions(10)
97 ->ReportAggregatesOnly()
98 ->Unit(benchmark::kMillisecond);
99
100BENCHMARK(BM_WriteVectors)
101 ->Iterations(3)
102 ->Repetitions(3)
103 ->Arg(1024 * 1024)
104 ->Arg(10 * 1024 * 1024)
105 ->Arg(100 * 1024 * 1024)
106 ->Arg(400 * 1024 * 1024)
107 ->ReportAggregatesOnly()
108 ->Unit(benchmark::kMillisecond);
109
110BENCHMARK(BM_ReadVectors)
111 ->Iterations(3)
112 ->Repetitions(3)
113 ->Arg(1024 * 1024)
114 ->Arg(10 * 1024 * 1024)
115 ->Arg(100 * 1024 * 1024)
116 ->Arg(400 * 1024 * 1024)
117 ->ReportAggregatesOnly()
118 ->Unit(benchmark::kMillisecond);
119
120#endif // RTCTK_COMPONENTFRAMEWORK_TEST_REPOSITORYIFV2BENCH_HPP
This class provides a wrapper for a data point path.
Definition dataPointPath.hpp:74
Definition fakeClock.cpp:15
Definition commandReplier.cpp:22
Header file for RepositoryIf and related base classes.
BENCHMARK(BmCorrelator) -> Ranges({{1, 16}, {1, 128}})
Register BmCorrelator benchmark with two ranges of arguments: 0: Number of topics 1: Number of data s...