17#include "benchmark/benchmark.h"
27 std::random_device
rd;
28 std::mt19937 mt(
rd());
29 std::vector<TestPoint> testPoints;
32 std::uniform_real_distribution<double> distX{xmin, xmax};
33 std::uniform_real_distribution<double> distY{ymin, ymax};
34 std::generate(testPoints.begin(), testPoints.end(), [&distX, &distY, &mt] {
35 return TestPoint{distX(mt), distY(mt)};
41static void segmentationList(benchmark::internal::Benchmark*
b)
44 for (
auto bending : {
true,
false}) {
56BENCHMARK_DEFINE_F(
BenchO2, ctor)
59 int detElemId =
state.range(0);
69 std::vector<int> deids;
71 [&deids](
int detElemId) { deids.push_back(detElemId); });
75static void benchCathodeSegmentationConstructionAll(benchmark::State&
state)
78 for (
auto _ :
state) {
79 for (
auto detElemId : deids) {
80 for (
auto bending : {
true,
false}) {
87BENCHMARK_DEFINE_F(
BenchO2, findPadByFEE)
88(benchmark::State&
state)
95 for (
auto _ :
state) {
98 for (
int ds = 0;
ds < nds; ++
ds) {
100 for (
int ch = 0; ch < 64; ch++) {
112BENCHMARK_DEFINE_F(
BenchO2, findPadByPosition)
113(benchmark::State&
state)
120 const int n = 100000;
124 for (
auto _ :
state) {
134BENCHMARK(benchCathodeSegmentationConstructionAll)->Unit(benchmark::kMillisecond);
std::vector< TestPoint > generateUniformTestPoints(int n, double xmin, double ymin, double xmax, double ymax)
BENCHMARK_REGISTER_F(BenchO2, findPadByPosition) -> Apply(segmentationList) ->Unit(benchmark::kMillisecond)
o2::mch::mapping::CathodeSegmentation seg
BENCHMARK(benchCathodeSegmentationConstructionAll) -> Unit(benchmark::kMillisecond)
std::vector< int > getDetElemIds()
A CathodeSegmentation lets you find pads on a given plane (cathode) of a detection element and then i...
int dualSampaId(int dualSampaIndex) const
int nofDualSampas() const
int findPadByPosition(double x, double y) const
int findPadByFEE(int dualSampaId, int dualSampaChannel) const
GLboolean GLboolean GLboolean b
int detElemId(Chamber chamber, Side side, int number)
void forOneDetectionElementOfEachSegmentationType(CALLABLE &&func)
o2::mch::contour::BBox< double > getBBox(const CathodeSegmentation &seg)