Project
Loading...
Searching...
No Matches
benchBitSet.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
12#include <benchmark/benchmark.h>
13#include <bitset>
14#include <array>
15#include "BitSet.h"
16#include <boost/multiprecision/cpp_int.hpp>
17
18constexpr uint64_t one{1};
19
20using namespace o2::mch::raw;
21
22static void BM_BitSetGet(benchmark::State& state)
23{
24 BitSet bs;
25 bs.grow(10024);
26 for (auto _ : state) {
27 for (int i = 0; i < 100; i++) {
28 bs.get(i);
29 }
30 }
31}
32
33static void BM_BitSetSet(benchmark::State& state)
34{
35 BitSet bs;
36 bs.grow(10024);
37 int a{0};
38 for (auto _ : state) {
39 for (int i = 0; i < 100; i++) {
40 bs.set(i, false);
41 }
42 }
43}
44
45static void BM_BitSetSetFast(benchmark::State& state)
46{
47 BitSet bs;
48 bs.grow(10024);
49 for (auto _ : state) {
50 for (int i = 0; i < 100; i++) {
51 bs.setFast(i, false);
52 }
53 }
54}
55
56using namespace boost::multiprecision;
57static void BM_Set(benchmark::State& state)
58{
59 typedef number<cpp_int_backend<16384, 16384, unsigned_magnitude, unchecked, void>> bigint;
60 bigint bs;
61 for (auto _ : state) {
62 for (int i = 0; i < 100; i++) {
63 bit_unset(bs, i);
64 }
65 }
66}
67
68using namespace boost::multiprecision;
69static void BM_Get(benchmark::State& state)
70{
71 typedef number<cpp_int_backend<16384, 16384, unsigned_magnitude, unchecked, void>> bigint;
72 bigint bs;
73 bool a;
74 for (auto _ : state) {
75 for (int i = 0; i < 100; i++) {
76 benchmark::DoNotOptimize(bit_test(bs, i));
77 }
78 }
79}
80
81// Register the function as a benchmark
82BENCHMARK(BM_BitSetSet);
83BENCHMARK(BM_BitSetGet);
84BENCHMARK(BM_BitSetSetFast);
85BENCHMARK(BM_Set);
86BENCHMARK(BM_Get);
87
88// Run the benchmark
int32_t i
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events Show standalone event Run event generator maximum time bin of continuous for triggered for automatic continuous for automatic continuous triggered uint64_t
SurfaceTrackState state
BENCHMARK_MAIN()
constexpr uint64_t one
BENCHMARK(BM_BitSetSet)
bool grow(int n)
Definition BitSet.cxx:234
void setFast(int pos, bool val)
Definition BitSet.cxx:288
bool get(int pos) const
Definition BitSet.cxx:225
void set(int pos, bool val)
Definition BitSet.cxx:277
GLboolean GLboolean GLboolean GLboolean a
Definition glcorearb.h:1233