RTC Toolkit 6.0.0
Loading...
Searching...
No Matches
repositoryIfBench.hpp
Go to the documentation of this file.
1
11
12#ifndef RTCTK_COMPONENTFRAMEWORK_TEST_REPOSITORYIFV2BENCH_HPP
13#define RTCTK_COMPONENTFRAMEWORK_TEST_REPOSITORYIFV2BENCH_HPP
14
16
17#include <benchmark/benchmark.h>
18
20static std::shared_ptr<RepositoryIf> MakeRepository();
21}
22
23// The function signature for the benchmarks is defined by the 3rd party library.
24// cppcheck-suppress constParameterCallback
25static void BM_WriteScalars(benchmark::State& state) {
26 using namespace rtctk::componentFramework;
27 using namespace rtctk::componentFramework::test;
28
29 auto repo = MakeRepository();
30 DataPointPath path{"/foo"};
31 rtctk::RtcFloat value = 42.0;
32 repo->CreateDataPoint(path, value);
33
34 for (auto _ : state) {
35 repo->WriteDataPoint(path, value);
36 }
37
38 repo->DeleteDataPoint(path);
39}
40
41// cppcheck-suppress constParameterCallback
42static void BM_ReadScalars(benchmark::State& state) {
43 using namespace rtctk::componentFramework;
44 using namespace rtctk::componentFramework::test;
45
46 auto repo = MakeRepository();
47 DataPointPath path{"/foo"};
48 rtctk::RtcFloat value = 42.0;
49 repo->CreateDataPoint(path, value);
50
51 for (auto _ : state) {
52 repo->ReadDataPoint(path, value);
53 }
54
55 repo->DeleteDataPoint(path);
56}
57
58// cppcheck-suppress constParameterCallback
59static void BM_WriteVectors(benchmark::State& state) {
60 using namespace rtctk::componentFramework;
61 using namespace rtctk::componentFramework::test;
62
63 auto repo = MakeRepository();
64 DataPointPath path{"/foo"};
65 rtctk::RtcVectorInt8 value(state.range(), 42);
66 repo->CreateDataPoint(path, value);
67
68 for (auto _ : state) {
69 repo->WriteDataPoint(path, value);
70 }
71
72 repo->DeleteDataPoint(path);
73}
74
75// cppcheck-suppress constParameterCallback
76static void BM_ReadVectors(benchmark::State& state) {
77 using namespace rtctk::componentFramework;
78 using namespace rtctk::componentFramework::test;
79
80 auto repo = MakeRepository();
81 DataPointPath path{"/foo"};
82 rtctk::RtcVectorInt8 value(state.range(), 42);
83 repo->CreateDataPoint(path, value);
84
85 for (auto _ : state) {
86 repo->ReadDataPoint(path, value);
87 }
88
89 repo->DeleteDataPoint(path);
90}
91
92BENCHMARK(BM_WriteScalars)
93 ->Iterations(100)
94 ->Repetitions(10)
95 ->ReportAggregatesOnly()
96 ->Unit(benchmark::kMillisecond);
97
98BENCHMARK(BM_ReadScalars)
99 ->Iterations(100)
100 ->Repetitions(10)
101 ->ReportAggregatesOnly()
102 ->Unit(benchmark::kMillisecond);
103
104BENCHMARK(BM_WriteVectors)
105 ->Iterations(3)
106 ->Repetitions(3)
107 ->Arg(1024 * 1024)
108 ->Arg(10 * 1024 * 1024)
109 ->Arg(100 * 1024 * 1024)
110 ->Arg(400 * 1024 * 1024)
111 ->ReportAggregatesOnly()
112 ->Unit(benchmark::kMillisecond);
113
114BENCHMARK(BM_ReadVectors)
115 ->Iterations(3)
116 ->Repetitions(3)
117 ->Arg(1024 * 1024)
118 ->Arg(10 * 1024 * 1024)
119 ->Arg(100 * 1024 * 1024)
120 ->Arg(400 * 1024 * 1024)
121 ->ReportAggregatesOnly()
122 ->Unit(benchmark::kMillisecond);
123
124#endif // RTCTK_COMPONENTFRAMEWORK_TEST_REPOSITORYIFV2BENCH_HPP
This class provides a wrapper for a data point path.
Definition dataPointPath.hpp:76
Definition fakeClock.cpp:14
Definition commandReplier.cpp:21
float RtcFloat
Definition basicTypes.hpp:45
RtcVector< RtcInt8 > RtcVectorInt8
Definition basicTypes.hpp:50
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...